How to send email using ASP and CDOSYS

The following ASP script can be used to send email using CDOSYS on our servers.

Dim iConfig
Dim theFlds
Dim objCDOMail

Set iConfig = Server.CreateObject ("CDO.Configuration")
Set theFlds = iConfig.Fields

'Set and update fields properties
theFlds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
theFlds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.servwise.com"
theFlds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
theFlds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
theFlds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
theFlds("http://schemas.microsoft.com/cdo/configuration/sendusername")="name@email.com"
theFlds("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

theFlds.Update

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDO.Message")
Set objCDOMail.Configuration = iConfig
Err.Clear

objCDOMail.From = "sender@emaladdress.com"
objCDOMail.To = "recipient@emaladdress.com"
objCDOMail.Subject = "Email Subject"
objCDOMail.TextBody="Email Body"
objCDOMail.Send

'Close the server mail object
Set objCDOMail = Nothing
Set theFlds= Nothing
Set iConfig = Nothing

You may also find the following useful http://www.w3schools.com/asp/asp_send_email.asp

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Error : Validation of viewstate MAC failed

If you get the error following error in your .NET app - Validation of viewstate MAC failed. If...

Configuring WebsitePanel to use your own Name Servers

If you have a reseller account you may want to use your own name servers with your customers...

Do we provide Secure SMTP, POP3, IMAP (SSL and TLS)?

SSL/TLS is supported for all email protocols.  Where your client supports it, you can use TLS on...

Information needed to generate a Certificate Signing Request (CSR)

Before reading this guide why not click here to take a look at our selection of wonderfull SSL...

What is an email "alias" and what is it for? (Windows Hosting)

What is an email alias and what is it for? (Windows Hosting) An email alias is an alternative...