Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an excerpt for my SMTP helper I use everyday.... </p> <pre><code>public bool SendMail(string strTo, string strFrom, string strCc, string strBcc, string strBody, string strSubject) { bool isComplete = true; SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try { //Default port will be 25 smtpClient.Port = 25; message.From = new MailAddress(smtpEmailSource); message.To.Add(strTo); message.Subject = strSubject; if (strCc != "") { message.Bcc.Add(new MailAddress(strCc)); } if (strBcc != "") { message.Bcc.Add(new MailAddress(strBcc)); } message.IsBodyHtml = true; string html = strBody; //I usually use .HTML files with tags (e.g. {firstName}) I replace with content. This allows me to edit the emails in VS by opening a .HTML file and it's easy to do string replacements. AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, new ContentType("text/html")); message.AlternateViews.Add(htmlView); // Send SMTP mail smtpClient.Send(message); } catch { isComplete = false; } return isComplete; } </code></pre> <p><strong>[UPDATE]</strong></p> <p>The key points as I originally left off...</p> <ol> <li><p>IsBodyHtml states that your message is HTML formatted. If you were only sending a single view of HTML, this is all you need.</p></li> <li><p>AlternateView is used to store my HTML, this is not required for sending a HTML message but it's required if you want to send a message that includes HTML and Plain Text, in case the receiver is unable to render the HTML.</p></li> </ol> <p>I took out my plainView above so this isn't obvious, sorry... </p> <p>The key here is that if you want to send a HTML formatted message you need to use IsBodyHtml = true (default is false) to have your content rendered as HTML.</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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