email from ASP with CDOSYS

This section contains the codes and resources related to Classic ASP and ASP.net languages.

email from ASP with CDOSYS

Postby MT Shahzad on March 21st, 2008, 7:41 pm

CDOSYS email component replaced the old Microsoft's email component CDONTS. It is recommended now to use CDOSYS instead of CDONTS when emailing from ASP.

Here is how to use CDOSYS to send email from ASP:
Code: Select all
<%

Set oMail = Server.CreateObject("CDO.Message")
Set oMailConfig = Server.CreateObject ("CDO.Configuration")

oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
oMailConfig.Fields.Update

Set oMail.Configuration = oMailConfig
oMail.From = "your-email@your-domain.com"
oMail.To = "recipient@another-domain.com"
oMail.Subject = "Here goes the email subject..."
oMail.HTMLBody = "Here goes the email body..."
oMail.Send

Set oMail = Nothing
Set oMailConfig = Nothing

%>
MT Shahzad
Web/Software Developer
http://mts.sw3solutions.com
User avatar
MT Shahzad
Site Admin
 
Posts: 300
Joined: February 29th, 2008, 8:11 am
Location: Muridke, Pakistan

Return to ASP / ASP.net

Who is online

Users browsing this forum: No registered users and 0 guests

cron