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.

<%
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "FROM_EMAIL"
objEmail.To = "TO_EMAIL"
objEmail.Subject = "Test Mail"
objEmail.Textbody = "Test Mail"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
If Not err.number=0 Then
    Response.write "ERROR: " & err.Description
    err.Clear
Else
    Response.write "Email sent to " & objEmail.To
end if
%>
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 Dundas Chart?

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

MySQL ODBC driver on Windows 2008 / 2012 server

We have installed MySQL 5.1 ODBC driver on Windows 2008 / 2012 shared hosting server.

How to use Dundas Upload?

Dundas upload control is a flexible and reliable component allows you to accept, save, and...

How to send emails through JMail?

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

How to use ASPUpload?

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