Frequently Asked Questions

Other Languages: Español Português - Brasil

Using CDOSYS to Send Email from Your Windows Hosting Account

Print this Article
Last Updated: December 9, 2014 3:32 PM

This article only applies to Web & Classic Windows Hosting. For more information, see What type of hosting account do I have?

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 sending SMTP email messages and can be used with our IIS 6 and IIS 7 Windows hosting accounts. The following code sample demonstrates how to create, format, and send email.

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. Our shared hosting servers allow for email attachments up to 30 MB.

// 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.

Our mail server will not send email containing a "From:" header entry of aol, gmail, yahoo, hotmail, live, aim, or msn.