1

We have a search webpart which gets the values from 3 lists and displays it in a format on a page. Now when a user click on the ShareMe button. It copies the item description and title and open a email window from outlook with the title and description in subject and body respectively. The body with description doesnt preserve the html i.e the spacing, links etc. Any suggestions

1

This has nothing to do with SharePoint.

Section 2 of RFC 2368 says that the body field is supposed to be in text/plain format, so you can't do HTML.

However even if you use plain text it's possible that some modern mail clients would render a URL as a clickable link anyway, though.

Reference - Is it possible to add an HTML link in the body of a MAILTO link

There is a workaround for that. You will have to modify your code somewhat as below. Render your HTML in a div and then send the innerHTML.

<div id="mailBody"> https://google.com </div>
<input type="button" value="SendMail" onclick="sendMail();">

<script>
function sendMail()
{
   var mailBody=document.getElementById('mailBody').innerHTML;
   window.location="mailto:yourmail@domain.com?subject=testHTMLinmail&body="+mailBody;
}
</script>

W3Schools - tryhtml_link_mailto - tested the code here and it somewhat works with anchor tags.

However, if it's a full html text and then it would be better to use SPUtility's SendMail method like the solution provided here - Send Mail using CSOM/REST

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.