6

Maybe I'm not seeing the obvious here. I'm using this library for sending mails. And I'm also using transactional templates.

A quick code example:

var msg = new SendGridMessage {From = new EmailAddress("my@email.com")};
var personlization = new Personalization {Tos = new List<EmailAddress> {new EmailAddress("some@email.com")}};
dynamic t = new System.Dynamic.ExpandoObject();
t.firstname = "John";
t.lastname = "Doe";
t.message = "a <br/> line <br/> break";
msg.TemplateId = "abcdefg";
personlization.TemplateData = t;
msg.Personalizations = new List<Personalization> {personlization};

var response = await client.SendEmail(msg);

I can see how to add content manually, text or html by using the htmlContent prop, but in this case I'm using a transactional template.

In the example above, the email comes through html encoded instead of creating the line breaks, and I want the personalizations to be html. In addition, the template is html.

user1447679
  • 3,076
  • 7
  • 32
  • 69

1 Answers1

8

The answer your looking for is here, the issue is the template you are using

Handlebars HTML-escapes values returned by a {{expression}}. If you don't want Handlebars to escape a value, use the "triple-stash", {{{.

Nurdism
  • 578
  • 1
  • 9
  • 20