I've been working on a project with a feature so that when I click a button, Outlook will open and the corresponding value stored in a variable will be in the in the body of the mail. I've tried the following code:
<html>
<head>
<title>Email This Code Snippet</title>
<script language="javascript">
function TriggerOutlook()
{
var sub = "Hi friend";
var bodycont = "<html><body>welcome</body></html>";
var body = escape(bodycont + String.fromCharCode(13));
window.location.href = "mailto:[email protected]"
+ "?body=" + body
+ "&subject=" + sub
;
}
</script>
</head>
<body>
<form id="form1">
<a href="#" onclick="TriggerOutlook()">Email this Codesnippet</a>
<input type="text" name="txtbody" id="txtbody">
</form>
</body>
</html>
But the body of the mail is <html><body>welcome</body></html>
in plain text, not HTML. How do I get it formatted as HTML?
Interestingly, your code works for me as-is when Thunderbird is the default system mailer. Apparently Thunderbird is smart enough to notice that the body starts with <html>
and switches to HTML-mail mode.
It would seem at first that to convince Outlook to behave similarly, you might try setting the Content-Type
header in the email to "text/html". However, I don't see how this is possible using mailto since you do not have control over the headers.
You can't. The mailto specification doesn't have that kind of control over the e-mail client invoked by the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With