Click here to Skip to main content
12,820,054 members (23,442 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


7 bookmarked
Posted 3 Apr 2014

Send Email using Classic ASP

, 3 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
This is a complete working example with code on how to send email using classic ASP.


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

You may also be interested in...


Comments and Discussions

QuestionTo: Pin
Member 1018411822-Jul-14 12:17
memberMember 1018411822-Jul-14 12:17 
AnswerRe: To: Pin
Code Help 201422-Jul-14 20:16
memberCode Help 201422-Jul-14 20:16 
GeneralRe: To: Pin
Member 1018411823-Jul-14 6:24
memberMember 1018411823-Jul-14 6:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 3 Apr 2014
Article Copyright 2014 by Code Help 2014
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid