Web Wiz - Solar Powered Eco Web Hosting

Sending Mail Using Classic ASP CDOSYS

Below you will find an example of sending email from your Web Wiz Hosted Website using Classic ASP CDOSYS.

In order to send email you will first need to Setup a Mailbox from your Hosting Control Panel to use to send your email.

You would then enter the email address for your mailbox where it has "you@your-email-here.com" and the password where it has "YourPasswordHere" in the example below.

If you are sending email from a "Contact Us" form on your website you may wish to use the website visitors address when replying to teh email. For this you would set a "ReplyTo" address with the visitors email address where you see "reply-to@your-email-here.com"

'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

'Set and update CDO Configuration
With objCDOSYSCon

' Specify the authentication mechanism to basic (clear-text) authentication cdoBasic = 1
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

'SMTP Server username
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "you@your-email-here.com"

'SMTP Server password
.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPasswordHere"

'Out going SMTP server
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.websitelive.net"

'SMTP port
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587

'TLS Encryption
.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = 1

'CDO Port (1=localhost 2=network)
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

'Update CDO Configuration

End With

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon

With objCDOSYSMail

'Who the e-mail is from, this needs to be the same as your SMTP Server username
.From = "<you@your-email-here.com>"

'Who the e-mail is sent to
.To = "<to@to-email-here.com>"

'Who to reply-to when replying to the email
.ReplyTo = "<reply-to@your-email-here.com>"

'The subject of the e-mail
.Subject = "Website Enquiry"

'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
.HTMLBody = "this is the body"
'.TextBody = "this is the body"

'Send the e-mail

End with

'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

Back To Hosting Knowledgebase Menu

Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.