Select Category
Sitemap Help Contact
print article

Send an E-mail Using ASP (CDOSYS)

For Windows packages

Follow the instructions below to send an e-mail using ASP.

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

For help sending mail using ASP.NET, please reference How do I send an e-mail in ASP.NET?

Using the example below as a test, you will have to replace some of the details already provided.

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

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
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: " &amp; Err.Description

Response.Write sMsg

For additional information, you may want to reference: