1and1 Help Centre Categories

print article

Send an E-Mail Using ASP (CDOSYS)

For Windows packages

Learn how to send E-mails using ASP (CDOSYS).

CDOSYS provide you with Collaboration Data Objects in order to send authenticated E-mails in ASP (requiring a username and password). Using the example below as a test, replace the details in the second block of code with your own data.

CONST SMTPSendUsing = 2 ' Send using Port (SMTP over the network)
CONST SMTPServer = "auth.smtp.1and1.co.uk"
CONST SMTPServerPort = 25
CONST SMTPConnectionTimeout = 10 'seconds

dim sSubject, sEmail, sMailBody, sFrom, sReadReceipt, sMsg
sSubject = "Test"
sEmail = "recipient@domain.com"
sMailBody = "This is a test message."
sFrom = "sender@domain.com"
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("http://schemas.microsoft.com/cdo/configuration/sendusing") = SMTPSendUsing
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPServerPort
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: