1and1 Help Center Categories

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 = "smtp.1and1.com"
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
.Update
end with
oMail.Configuration = oConfig

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

oMail.Send
set oMail=nothing

sMsg = "Message Sent"

if Err.Number &lt;&gt; 0 then sMsg = "ERROR: " &amp; Err.Description

Response.Write sMsg

%>
For additional information, you may want to reference: