Creating mailto links in SharePoint with newlines / carriage returns

Standard

Creating a mailto: link is usually easy. You just generate a string in the form, e.g.:

email@address.com?subject=sub&body=bodytext

where sub and body are URL encoded strings. The URL encoding means, for example, you change spaces to %20 and newlines to %0A%0D, among others.

The problem with SharePoint is that if you paste the escaped string into the HTML view of a content editor web part, SharePoint, in all it’s wisdom, Converts the escaped strings back into normal text, which means all the newlines (and multiple spaces) are stripped.

This makes it seemingly impossible to create a mailto link with newlines.

Here’s the solution:
Continue reading