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:
The solution is to use JavaScript instead, and paste the lines unescaped into the script. Then make a basic mailto: link as before, but give it an id (in this case, the id is mailtolink
). Then the mailto link is overwritted with our desired link, complete with newlines, when the page loads.
<p>Please <a href="mailto:address@example.com" id="mailtolink">contact us</a>.</p>
<script type="text/javascript">
// <![CDATA[
var msgRec = 'address@example.com';
var msgSub = 'This is the message subject';
var msgBody = 'This is the full e-mail body\n\nThis is a new line\nAnd another line';
function modifyMailtoLink;
document.getElementById('mailtolink').href = 'mailto:' + encodeURIComponent(msgRec) + '?subject=' + msgSub + '&body=' + encodeURIComponent(msgBody);
};
_spBodyOnLoadFunctionNames.push('modifyMailtoLink');
// ]]>
</script>
Hey There. I discovered your blog the usage of msn. This
is a really well written article. I’ll be sure to bookmark it and come back to learn extra
of your helpful information. Thank you for the post. I’ll
definitely comeback.
If you arre going for bdst contents like I do, simply go too see
this websie daily because it gives quality contents, thanks
online casino slot казино франк онлайн-казино paysafe
Garrett can see what his father is doing unconsciously his hands moves to his cock. He strokes the length of his tool with his left hand while he teases the blistering red crown with the fingertips of his right hand. The lightning of his cool fingertips sends sparks through every nerve in his body. “I figured you did.” His father says. “You play on a team so you know the purpose of teamwork.”