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 send emails using ASP.Net (VB)?

This topic includes the sample code to send email from ASP.Net(VB) code :Sample Code :<%@...

How to send email through CDONTS Email?

CDONTS stands for "Collaboration Data Objects for Windows NT Server" and as the name suggests it...

How to use ASPSMS?

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

How to send emails through JMail?

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

MySQL ODBC driver on Windows 2008 / 2012 server

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