How to send email using CDOSYS with ASP or ASP.NET code?

Here is a working example to Download.


// using System.Web.Mail;
eMail = new MailMessage();
eMail.BodyFormat = MailFormat.Text;
eMail.From = _SendFrom;
eMail.Fields[http://schemas.microsoft.com/cdo/configuration/smtpserver]="mail.yourdomain.com";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"]=25;
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]=2;
if (SMTPUser != null && SMTPPassword != null)
{
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"]=1;
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "User@domain.com";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]="Password";
}
eMail.To = "recipients";
SmtpMail.SmtpServer = SMTPServerName;
SmtpMail.Send(eMail);


For ASP

 

Dim objMail, objConf
Set objMail = Server.CreateObject("CDO.Message")
Set objConf = Server.CreateObject ("CDO.Configuration")
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.yourdomain.com"
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user@yourdomain.com"
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"
objConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objConf.Fields.Update

Set objMail.Configuration = objConf
objMail.From = "sales@yourdomain.com"
objMail.To = "customer@domain.com"
objMail.Subject = "Message from the website"
objMail.HTMLBody = "Welcome to our website......"
objMail.Send
Set objMail = Nothing
Set objConf = Nothing


  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

How to setup Outlook to get my emails?

Please follow below link for step-by-step instructions and screenshots:  

How to setup Secure SMTP and POP3 Account over SSL?

If you are using our Windows hosted plan with Helm and Imail Server, please follow these...

How to select multiple emails as there are no checkboxes in Webmail (Windows platform with IPSwitch Imail Server)

Follow these instructions to select multiple emails in webmail interface on Windows platform and...

How to Change Email SMTP Port from 25 to 26 or 587

Many ISPs are now blocking SMTP traffic on port 25.  If you are unable to send emails but are...