Code
System.Web.Mail.MailMessage email = new System.Web.Mail.MailMessage();
email.From = "noreply@xxx.xx";
if (ccemail) email.Cc ="cc@xx.com";
email.To ="email@xx.com";
email.Subject = title;
email.BodyFormat = System.Web.Mail.MailFormat.Html;
email.Body = content;
SmtpClient smtp = new SmtpClient();
Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("~/");
MailSettingsSectionGroup msg = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
string username = msg.Smtp.Network.UserName.ToString();
string password = msg.Smtp.Network.Password.ToString();
string smtpurl = msg.Smtp.Network.Host.ToString();
System.Web.Mail.SmtpMail.SmtpServer = smtpurl;
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
System.Web.Mail.SmtpMail.Send(email);
System.Web.Mail.MailMessage email = new System.Web.Mail.MailMessage();
email.From = "noreply@xxx.xx";
if (ccemail) email.Cc ="cc@xx.com";
email.To ="email@xx.com";
email.Subject = title;
email.BodyFormat = System.Web.Mail.MailFormat.Html;
email.Body = content;
SmtpClient smtp = new SmtpClient();
Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("~/");
MailSettingsSectionGroup msg = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
string username = msg.Smtp.Network.UserName.ToString();
string password = msg.Smtp.Network.Password.ToString();
string smtpurl = msg.Smtp.Network.Host.ToString();
System.Web.Mail.SmtpMail.SmtpServer = smtpurl;
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
System.Web.Mail.SmtpMail.Send(email);