CDO How to Example's

Please Note - CDONTS object library doesn't work on Windows 2003.
We recommend using CDO instead of CDONTS on all Windows servers, since it is a newer and more flexible.

 

// Example 1

< %
set objMail=CreateObject("CDO.Message")
objMail.To="Target@mail.net"
objMail.From="Source@Mail.net"
objMail.Subject="my test"
objMail.HTMLBody = "hello"
objMail.Send
set objMail=Nothing
%>

// Example 2

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
< !--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->

<%
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
Dim iConf
Set iConf = CreateObject("CDO.Configuration")
Dim Flds
Set Flds = iConf.Fields
With Flds
' assume constants are defined within script file
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.server.net"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "Target@soft.net" 'ToDo: Enter a valid email address.
.From ="Source@godurango.com" 'ToDo: Enter a valid email address.
.Subject = "This is a test CDOSYS message (Sent via Port 25)"
.HTMLBody = strHTML
.Send
End With
Response.Write("Sent")
%>