1

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

Deinonychus
  • 135
  • 1
  • 9
  • Are you viewing the plaintext body of the message maybe? If so, SendGrid is likely adding the URL there for direct clicking, but it's not actually HTML. If you "Show Original" in GMail, you can see the raw body, and see what's actually being done. – jacobmovingfwd Apr 02 '19 at 20:20
  • @jacobmovingfwd Actually I don't think I'm viewing the plain text body. I don't see any HTML in the Show Original viewer... I see exactly this: ```Follow this link http://www.website.com to accept the invitation and get started.``` – Deinonychus Apr 02 '19 at 20:25
  • Actually now I have no idea what happened, but I receive this: ```Follow this link ( http://www.website.com ) to accept the invitation and get started.``` with the parenthesis and all. HTML has not changed. I may be going crazy. – Deinonychus Apr 02 '19 at 21:19

1 Answers1

1

@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);

Deinonychus
  • 135
  • 1
  • 9