How to send mail using CDO

<%
set objMessage = createobject("cdo.message")
set objConfig = createobject("cdo.configuration")

' Setting the SMTP Server
Set Flds = objConfig.Fields
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
Flds.update


Set objMessage.Configuration = objConfig
objMessage.To = "you@YourHostedDomainName.com"
objMessage.From = "someone@somewhere.com"
objMessage.Subject = "This is a sample email sent using CDO"
objMessage.TextBody = "Congratulation" & VbCrLf & "If you receive this is, your mail component works"
objMessage.fields.update
objMessage.Send

Response.write "Mail sent..."

set objMessage = nothing
set objConfig = nothing
%>


If you run into problems when using this code, please post in our community forum. Technical support is unable to assist with specific coding issues.

Article ID: 368, Created On: 11/24/2008, Modified: 4/13/2010