Click here to Skip to main content
Click here to Skip to main content

Send Email using Classic ASP

By , 3 Apr 2014
Rate this:
Please Sign up or sign in to vote.


This tip explains how to send email using classic ASP. I am using gmail as relay server in this tip.


I have seen a lot of people trying to send emails using classic ASP, but face some issues. Although there are lot of code snippets available, but here I am sharing a complete working ASP file that can be used to send emails.

Using the Code

In this example, I will use CDO.Message for sending email from classic ASP code. The code is tested using a Gmail account, but you can use any valid email account from any provider. The attached file is a complete working example and is tested in live setup. To test this example, you have to set the SMTP server and authentication information. Here is the explanation of the code.

To send email, first of all, create an object of CDO.Message:

dim objMail 
Set objMail = Server.CreateObject("CDO.Message") 

Set the SMTP server and authentication information:

dim smtpServer, yourEmail, yourPassword
smtpServer = ""
yourEmail = ""     'replace with a valid gmail account
yourPassword = "yourpassword"   'replace with a valid password for account set in yourEmail 

Replace and yourpassword with the email id and password of a valid gmail account.

Now set the various configuration properties:

objMail.Configuration.Fields.Item("") = 2
objMail.Configuration.Fields.Item("") = smtpServer
objMail.Configuration.Fields.Item("") = 1
objMail.Configuration.Fields.Item("") = 465 
objMail.Configuration.Fields.Item("") = true
objMail.Configuration.Fields.Item("") = yourEmail
objMail.Configuration.Fields.Item("") = yourPassword
objMail.Configuration.Fields.Item("") = 60 

Now prepare your actual message and send email using Send method.

objMail.Subject="Application Form Registration Details"
objMail.htmlBody = "This is test message"

Points of Interest

The default port for SMTP is 25. If you are using gmail server, i.e.,, then you have to use port number 465. Whichever SMTP server you are using, set the smtpserver and smtpserverport according to that. Most people face the issue in email due to incorrect port number.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Code Help 2014
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 3 Apr 2014
Article Copyright 2014 by Code Help 2014
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid