0

I have an email template that has a section like this

<p>Customer's Name: $CustomerName</p>

The problem is whenever $CustomerName token is replaced with a text that has '&' symbol it will create another </p> tag in the HTML body when it's opened in the browser.

<p>Customer's Name: John & Doe </p></p>

Thing(s) I've done

  1. Check generated email body: I've checked the logs, the email body looks good to me. It doesn't have additional </p> tag
  2. Try a different browser: I tried on Edge and Chrome the result is the same
  3. Try a different email provider: I tried on Gmail and One Drive the result is the same

Any idea what might cause this?

Thanks in advance

Cuppyzh
  • 142
  • 2
  • 10

1 Answers1

0

Based on the feedback I re-investigated the flow of code.

I found the root cause of the issue

  • HTML template that I used was already encoded
  • The token is not encoded

These condition make this:

Email before decode

&lt;p style=" color: #4a4a4a; font-family: Helvetica, Arial, sans-serif; font-size: 14px; display: block; margin-bottom: 10px; margin-top: 0; outline: none !important; " &gt; Organisation Name: * **ppyzh & 2 &lt;/p&gt; 

Email after decode

 <p style=" color: #4a4a4a; font-family: Helvetica, Arial, sans-serif; font-size: 14px; display: block; margin-bottom: 10px; margin-top: 0; outline: none !important; " > Organisation Name: * **ppyzh & 2 &lt;/p>

Reference: HttpUtility.HtmlDecode fails to decode &#39


Thanks for everyone that gave the feedback

Cuppyzh
  • 142
  • 2
  • 10