Sendgrid email sending having issue with apostrophe ’ character?

email, encoding, java, sendgrid

Solution

I know this answer is 6.5 years too late for you but, as the issue is still happening for people and this post appears high up in google search,I thought I would offer an alternative solution.

On the template itself in SendGrid, you can simply escape these problematic characters by using a triple curly brace as opposed to a double. i.e.

{{{recipient_name}}}

instead of

{{recipient_name}}

This solution is hidden within the bowels of SendGrid documentation:

https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/helpers/constants/index.js

Problem

I'm trying to send emails using SendGrid with Java. The apostrophe character appears like a ? (question mark). I am sending the header to have text encoding as UTF-8 but it still appears like a question mark. ``` mailMessage.setHeaders("{'text':'UTF-8'}"); ``` The above line has no effect. I am sure that the input HTML string I have is UTF-8 encoded. The email client is MS Outlook 2010

Original source