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 = _
Const cdoSendUsingPort = 2
Const cdoSMTPServer = _
Const cdoSMTPServerPort = _
Const cdoSMTPConnectionTimeout = _
Const cdoSMTPAuthenticate = _
Const cdoBasic = 1
Const cdoSendUserName = _
Const cdoSendPassword = _
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"
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()
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.

Looking to send emails using CDONTS? Click on Send > CDO Email for more details.

Related Articles

How to send emails through JMail?

We have installed JMail on our Windows shared servers. You can use following sample script to...

ASPJpeg support on Windows 2008 / 2012 servers

We don't provide the ASPUpload components on our Windows Shared Hosting customers. Windows VPS...

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

We don't offer Windows 2008 or Windows 2012 Shared Hosting Service anymore but we now offer...

How to use ASP Simple Upload component?

Sample code: <% Option Explicit Dim upl, NewFileName Set upl =...

How to use ASPUpload?

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

  • 0 Users Found This Useful

Was this answer helpful?