Frequently Asked Questions

How Do I Use CDOSYS to Send Email?

Last Updated: January 11, 2007 11:02 AM

CDOSYS is part of the System.Web.Mail namespace and is installed by default on Windows 2000 and Windows XP platforms. It replaces CDONTS for the sending of SMTP email messages and can be used with our Windows hosting accounts. The following code sample demonstrates how CDOSYS is used to create, format, and send email.

NOTE: The server "relay-hosting.secureserver.net" is used to send email from your hosted domain. You must populate the SmtpMail object's SmtpServer property with this value.

NOTE: Our shared hosting servers allow for the sending of attachments not exceeding 30 MB in size.

// language -- C#
// import namespace
using System.Web.Mail;

private void SendEmail()
{
   const string SERVER = "relay-hosting.secureserver.net";
   MailMessage oMail = new System.Web.Mail.MailMessage();
   oMail.From = "emailaddress@domainname";
   oMail.To = "emailaddress@domainname";
   oMail.Subject = "Test email subject";
   oMail.BodyFormat = MailFormat.Html; // enumeration
   oMail.Priority = MailPriority.High; // enumeration
   oMail.Body = "Sent at: " + DateTime.Now;
   SmtpMail.SmtpServer = SERVER;
   SmtpMail.Send(oMail);
   oMail = null; // free up resources
}

For more information about CDOSYS, see MSDN.