Support Center » Knowledgebase » How to send email using CDOSYS from your ASP script

How to send email using CDOSYS from your ASP script

CDONTS is no longer supported by Microsoft, and subsequently dropped from Windows 2003, existing code should be migrated to CDOSYS, the new API from Microsoft. This article presents an example that sends an email using CDOSYS.

In this code below, please replace to accordingly.
' send by connecting to port 25 of the SMTP server
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strSmartHost

Const cdoSendUsingPort = 2
StrSmartHost = ""

set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

' set the CDOSYS configuration fields to use port 25 on the SMTP server

With Flds
  .Item("") = cdoSendUsingPort
  .Item("") = strSmartHost
  .Item("") = 10
  ' Use SMTP authentication 
  .Item ("") = 1 'basic (clear-text) authentication 
  .Item ("") = "" 
  .Item ("") = "emailpassword" 
End With
' build HTML for message body
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

' apply the settings to the message
With iMsg
Set .Configuration = iConf
.To = ""
.From = ""
.Subject = "This is a test CDOSYS message (Sent via Port 25)"
.HTMLBody = strHTML
End With

' cleanup of variables
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing


The above example came from:

Article Details
Article ID: 88
Created On: 03 Oct 2004 05:00 AM
 Login [Lost Password] 
Remember Me:
Please note that the login and password to the support area is NOT the same as your hosting control panel login and password
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Downloads | Control Panel User's Guide | Server Status