Note that there are some explanatory texts on larger screens.

plurals
  1. POPorting System.Web.Mail functionality to System.Net.Mail
    primarykey
    data
    text
    <p>The following function works perfectly:</p> <pre><code> protected void SendWebMailMessage(string DisplayName, string From, string ReplyTo, string To, string Subject, string Body, string Attachments) { System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage(); msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtpout.secureserver.net"); msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25); msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2); msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1); msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername", From); msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword", mailpassword); msg.To = To; msg.From = DisplayName + "&lt;" + From + "&gt;"; msg.BodyFormat = MailFormat.Html; msg.Subject = Subject; msg.Body = Body; msg.Headers.Add("Reply-To", ReplyTo); SmtpMail.SmtpServer = "smtpout.secureserver.net"; SmtpMail.Send(msg); } </code></pre> <p>However, I get a build warning telling me that System.Web.Mail is obsolete, and that I should be using System.Net.Mail. So I used System.Net.Mail, and I came up with the following function to replace my old one:</p> <pre><code> protected void SendNetMailMessage(string DisplayName, string From, string ReplyTo, string To, string Subject, string Body, string Attachments) { MailAddress addrfrom = new MailAddress(From, DisplayName); MailAddress addrto = new MailAddress(To); MailAddress replytoaddr = new MailAddress(ReplyTo); System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.From = addrfrom; msg.To.Add(addrto); msg.ReplyTo = replytoaddr; msg.IsBodyHtml = true; SmtpClient smtp = new SmtpClient("smtpout.secureserver.net"); smtp.Credentials = new NetworkCredential(From, mailpassword); smtp.Send(msg); } </code></pre> <p>I don't get any exceptions or errors, but my message never goes through. Can anyone tell me what I might be doing wrong? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload