CDONTS vs CDOSYS for ASP Email

CDONTS was deprecated and replaced by CDOSYS in Winddows 2003.  You can still install and use CDONTs if you need it though.  Just google for CDONTS and register the DLL.

CDONTS Example:

<%
Option Explicit

Dim objMail
Dim strSubject
Dim strBody

strSubject = “This is a test email in HTML format”

strBody = “<HTML>” & _
“<HEAD></HEAD>” & _
“<BODY>” & _
” <Font Face=Arial Size=5><B>” & _
”  This is a test Email” & _
” </B></Font><BR>” & _
” <H3><A Href=http://www.mydomain.com>Click here</a>” & _
” to go to DevASP.com</h3>” & _
“</BODY>” & _
“</HTML>”

Set objMail = Server.CreateObject(“CDONTS.NewMail”)

objMail.From    = “test@mydomain.com”
objMail.To      = “someone@mydomain.com”
objMail.Subject = strSubject
objMail.Body    = strBody

objMail.MailFormat = 0
objMail.BodyFormat = 0

objMail.Send

Set objMail = Nothing
%>

CDOSYS Example:

<%
sch = “http://schemas.microsoft.com/cdo/configuration/”

Set cdoConfig = CreateObject(“CDO.Configuration”)

With cdoConfig.Fields
.Item(sch & “sendusing”) = 1
.Item(sch & “smtpserverpickupdirectory”) = “c:\inetpub\mailroot\pickup”
.update
End With

Set cdoMessage = CreateObject(“CDO.Message”)

With cdoMessage
Set .Configuration = cdoConfig
.From = “<anything>@<domain>”
.To = “<anything>@<domain>”
.Subject = “CDO Message”
.TextBody = “This is a test for CDO.message”
.Send
End With

Set cdoMessage = Nothing
%>

You can leave a response, or trackback from your own site.

Leave a Reply