Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does CDONTS return success/failure status?

Status
Not open for further replies.

multiplex77

Programmer
Dec 25, 2001
302
SG
Hi,

I'm using CDONTS to send out emails in ASP.

Set objMail = CreateObject("CDONTS.NewMail")
objMail.From = "me@myco.com"
objMail.To = "youyourco.com" 'bad email
objMail.Subject = "Demo"
objMail.Body = "Message"
objMail.Send

The problem is that it doesn't return any result, whether the mail was sent or not.

Questions:
1. is it true that even if the parameters are wrong, like the eg above, there is no error message returned?

2. How can I determine if the mail was successfully sent or not?

Thanks for the help.
 
Questions:
1. is it true that even if the parameters are wrong, like the eg above, there is no error message returned?

if the parameters are incorrect then the mail will not be sent. you may not recieve a error and see nothing in effect happen when the mail is sent or attempted to be sent. that is what error handling is for.

2. How can I determine if the mail was successfully sent or not?
do this after the .send
Response.write("Mail was Sent")


I don't see anything wrong with the code you provided. was there some kind of error or was this just a reference question A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
onpnt,

Thanks for your reply.

It's good that CDONTS does not error out when a parameter is wrong, but I need some confirmation that there was no error. In the eg. I gave, the "To" field was an invalid email, but if I write Response.Write("Mail sent") after the .Send call, it will indicate that it was sent, even though the email was actually bad.

It was just an example I gave. In my actual code, the To and From fields are all dynamically assigned, so they may be invalid emails, etc.

So I guess the only way would be to check the email validity before invoking CDONTS.

Thanks so much for the help! :)
 
So I guess the only way would be to check the email validity before invoking CDONTS
Yes!

I suggest doing this in the form though via client side. then if it's wrong you never get to this stage in the process.
A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top