nathan schmoll's
aspdiscovery

back to main page

e-mail me








How to use CDONTS to send e-mail
For sending e-mail from an ASP file, we ASPers always had to get some extra component and install it on our server . . . until IIS4 and NT option pack 4. Now there is a component that's included called CDONTS that comes with IIS4. You must have option pack 4 or later because it includes a built-in SMTP service! To send a regular text-based e-mail from an ASP, we will use this simple code:

<%
dim msgbody
dim cdomail
set cdomail=createobject("cdonts.newmail")
cdomail.from="you@yourface.com"
cdomail.to="me@myface.com"
cdomail.subject="Thanks for ordering that thingy _
from us!"
cdomail.body="Thank you for ordering that thing!" _
& vbcrlf & "We appretiate your business and hope _
you will return soon." & vbcrlf & "Your stuff _
will arrive within 7 business days."
cdomail.send
%>

Do you know what those vbcrlf's are for? They tell the script to go to the next line in the e-mail. If you were sending an e-mail and you wanted to start a new paragraph, you would just add two vbcrlf's!

copyright © 2001, nathan schmoll. all rights reserved. questions? comments? suggestions? e-mail me!