title: HttpUtility.HtmlEncode loosing HTML tags in email
body: <p>I'm trying to send emails which contains html tags using the following code.</p>
  <pre><code>string host = &quot;smtp.office365.com&quot;, subject = &quot;&quot;, fromAddr = &quot;fromAddress&quot;;
              SmtpClient client = new SmtpClient(host, 587);
              MailMessage msg = new MailMessage();
              msg.From = new MailAddress(fromAddr);
              msg.Subject = subject;
              msg.IsBodyHtml = true;
              string emailBody = &quot;Hello &lt;strong&gt;World&lt;/strong&gt;&quot;;
              msg.Body = System.Web.HttpUtility.HtmlEncode(emailBody);
              string toAddrList = &quot;toaddress&quot;;
              foreach (string addr in toAddrList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
              {
                  msg.To.Add(addr.Trim());
              }
  
              System.Net.NetworkCredential credential = new System.Net.NetworkCredential(&quot;email&quot;, &quot;pass&quot;, &quot;&quot;);
              client.UseDefaultCredentials = false;
              client.Credentials = credential;
              client.EnableSsl = true;
              client.Send(msg);
  </code></pre>
  <p>The emails are being sent but html tags are not being render, emails are received with simple text like</p>
  <p><a href="https://i.stack.imgur.com/9xGdw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9xGdw.png" alt="enter image description here" /></a></p>
  <p>But if I remove System.Web.HttpUtility.HtmlEncode method and pass the emailBody as it is, then it renders html tags properly in email.</p>
  <p>Can someone please tell me how can I make it work so that I dont have to remove the System.Web.HttpUtility.HtmlEncode method and keeping html tags as well.</p>
  <p>Thanks</p>