Sample script for CDO email

CDO (Collaboration Data Objects) is an inbuilt ASP component used to send emails via ASP. It is widely used as a CDONTs replacement, because Microsoft discontinued the use of CDONTs on Windows 2000, Windows XP and Windows 2003 OS. CDO is the best choice to send emails from ASP based web applications, as it comes pre-installed with server OS like, Windows Server 2003, 2008 and 2012.

If you are still using CDONT component in your ASP application to send emails, you should update your code to use CDO. Below is a basic CDO script you can use to send emails. It's just a basic script, and you may have to customize it according to your requirements. You can find lots of web pages on the internet with more customizations and attributes with CDO.

 

<%
Const cdoSendUsingMethod = _
"http://schemas.microsoft.com/cdo/configuration/sendusing"
 
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = _
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = _
"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
 
Const cdoSMTPAuthenticate = _
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = _
"http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = _
"http://schemas.microsoft.com/cdo/configuration/sendpassword"
 
Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields
 
' Get a handle on the config object and it's fields
objConfig = Server.CreateObject("CDO.Configuration")
Fields = objConfig.Fields
 
' config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail server name"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "Email account "
.Item(cdoSendPassword) = "Password"
 
.Update
End With
 
objMessage = Server.CreateObject("CDO.Message")
 
 
objMessage.Configuration = objConfig
 
With objMessage
.To = "emailAddress"
.From = "emailAddress"
.Subject = "SMTP Relay Test"
 
.TextBody = "SMTP Relay Test Sent @ " & Now()
.Send
End With
 
Fields = Nothing
objMessage = Nothing
 
objConfig = Nothing
%>

If you run into any problems while using this script, you can contact AccuWebHosting support with the exact error message or URL.

Note: You should always clean your email list using email verification tool before starting an email campaign.


  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to use ASPSMS?

Here is the ASP VB-Script example, intended to be used on an IIS (Internet Information Server)...

Microsoft Access and ASP connection script for Windwos 2008 / 2012 shared hosting

If your website is hosted on our Windows 2008 or Windows 2012 shared hosting server, you will...

How to use Dundas Chart?

How to create a Basic Pie Chart with Dundas Chart To use this control in a web site, you will...

How to create ASPNETDB database using aspnet_regsql tool?

What is ASPNETDB? Microsoft has introduced a new and powerful default database schema in...

How to use ASPUpload?

ASPUpload is a COM+ component, which enables an ASP application to capture, save and process the...