Search code examples
sendgridsendgrid-templates

How to correctly display links using Legacy templates?


I'm trying to send an email using substitutions with a legacy template. Some of the substitutions are URLs, that I want to display using an tag. My problem is that everything in the href attribute gets outputted when it really should not.

For example, here's a line in my email template.

<a href="-acceptUrl-">Follow this link</a> to accept the invitation and get started.

The following gets outputed in the email (received in Gmail):

Follow this link http://www.website.com to accept the invitation and get started.

The WYSIWYG in SendGrid displays the correct format:

https://imgur.com/YmtstCF

Another example is when I try to display the URL itself and make it clickable:

Twitter: <a href="-twitterUrl-">-twitterUrl-</a><br />

This is what I receive in Gmail:

Twitter: http://twitter.com/xxx http://twitter.com/xxx

And the correct format:

enter image description here


Solution

  • @jacobmovingfwd had the right idea, but the correct answer is from the sending side.

    I'm using the SendGrid for C# API. The following line was incorrect:

    msg.AddContent(MimeType.Text, parameters.Body);

    I thought the AddContent method was used only for the <%body%> tag of the template. But apparently it sets the mime type for all of the template. So I fixed it by changing the line to:

    msg.AddContent(MimeType.Html, parameters.Body);