||Before you can successfully send an email using CDONTS, you must have the SMTP Service setup correctly on your Web server. To learn more about this process be sure to read Getting Starting: The SMTP Service. This FAQ will not delve into the specifics of this task.|
Assuming the SMTP Service is setup correctly and the CDONTS component was installed with the NT Option Pack, sending an email using CDONTS couldn't be easier. All you have to do is create the object, set some properties, and call the
Send method! That's it!
The main properties we are interested in are:
Body. Once we set these properties, a simple call to the
Send method shoots off the email! Below you will see a sample script provided by Rob Taylor:
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "email@example.com"
objMail.Subject = "How TO send email with CDONTS"
objMail.To = "firstname.lastname@example.org"
objMail.Body = "This is an email message" & vbcrlf&_
"with CDONTS." & vbcrlf&_
"It is really easy. "
Response.write("Mail was Sent")
'You must always do this with CDONTS.
set objMail = nothing
When using the CDONTS object, be sure to set both the
From properties, or the email won't be sent!
To send an email to multiple recipients you can specify multiple email addresses in the
.To property - simply separate each email address by a comma. For a more thorough examination of CDONTS properties be sure to check out: Sending Emails in ASP Using CDONTS. Also, to learn how to send attachments using CDONTS, check out this FAQ: How do you send email attachments using CDONTS?
To learn more about sending emails, be sure to check out: Learn More About Sending Emails with ASP!