For Windows Web Hosting packages

In this article, we'll provide an example that you can adapt with your own details to send an email using ASP.

CDOSYS, which replaced CDONTS in 2000, provides you with Collaboration Data Objects in order to send authenticated emails (requiring a username and password) in ASP.

Guided Steps

  • Copy the text from the box below and paste it into a text editor, such as NotePad.
  • Edit the details shown below in this color.
  • Save the file with the extension .asp (Ex: sendmail.asp).
  • Upload the file to your webspace.
  • Access the file through your browser to verify that it works (Ex:

CONST SMTPSendUsing = 2 ' Send using Port (SMTP over the network)
CONST SMTPServer = ""
CONST SMTPServerPort = 465
CONST SMTPConnectionTimeout = 10 'seconds

CONST SMTPPassword = "EnterEmailPasswordHere"

dim sSubject, sEmail, sMailBody, sFrom, sReadReceipt, sMsg
sSubject = "Test"
sEmail = ""
sMailBody = "This is a test message."
sFrom = ""
sReadReceipt = true
sMsg = ""

On Error Resume Next

dim oMail, oConfig, oConfigFields
set oMail = Server.CreateObject("CDO.Message")
set oConfig = Server.CreateObject("CDO.Configuration")
set oConfigFields = oConfig.Fields

with oConfigFields
.Item("") = SMTPSendUsing
.Item("") = SMTPServer
.Item("") = SMTPServerPort
.Item("") = 1
.Item("") = SMTPUser
.Item("") = SMTPPassword
.Item("") = True
.Item("") = True
end with
oMail.Configuration = oConfig

oMail.Subject = sSubject
oMail.From = sFrom
oMail.To = sEmail
oMail.HTMLBody = sMailBody

set oMail=nothing

sMsg = "Message Sent"

if Err.Number > 0 then sMsg = "ERROR: " & Err.Description

Response.Write sMsg


If the test message was received by the email account with which you replaced in the example shown above, you can now adapt the script to better fit your usage, such as by replacing the sSubject and sMailBody values.