HTML Email with StringBuilder not picking HTML (raw code was sent in email)

Discussion in 'Email' started by Senor Engineer, Sep 26, 2014.

  1. Hi,

    I need some help, I used the below DiscountASP email client code. It works, but instead of showing as HTML (opening email), raw html code has been sent to the users. I tested with GMail account in my local database it works, but when I deployed the code it fails when sending email via DiscountASP, any help ...

    I used below. Is there a quick way of convertng stringbuilder value to HTML before sending email ?

    mail.Body = sb.ToString();


    MailMessage mail = new MailMessage();

    mail.From = new MailAddress(strFrom, "#CompanyName#", System.Text.Encoding.UTF8);

    mail.To.Add(strTo);

    if (strCc != "") { mail.CC.Add(strCc); }
    if (strBcc != "") { mail.To.Add(strBcc); }

    mail.Subject = emailsubject;
    mail.Body = sb.ToString();

    SmtpClient smtp = new SmtpClient("smtp.SITENAME.com");

    NetworkCredential credential = new NetworkCredential("****@****.com", "******");
    smtp.Credentials = credential;
    smtp.Send(mail);
     
  2. FrankC

    FrankC DiscountASP.NET Staff

    Add this to your code

    mail.IsBodyHtml = true;
     
    martino and mjp like this.
  3. Awesome !

    Thanks for the quick help !!!!! It works.
     
    RayH, martino and mjp like this.

Share This Page