Is it possible to add an HTML link in the body of a MAILTO link
Solution 1
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.
Solution 2
Add the full link, with:
"http://"
to the beginning of a line, and most decent email clients will auto-link it either before sending, or at the other end when receiving.
For really long urls that will likely wrap due to all the parameters, wrap the link in a less than/greater than symbol. This tells the email client not to wrap the url.
e.g.
<http://www.example.com/foo.php?this=a&really=long&url=with&lots=and&lots=and&lots=of&prameters=on_it>
Solution 3
It isn't possible as far as I can tell, since a link needs HTML, and mailto links don't create an HTML email.
This is probably for security as you could add javascript or iframes to this link and the email client might open up the end user for vulnerabilities.
Solution 4
Please check below javascript in IE. Don't know if other modern browser will work or not.
<html>
<head>
<script type="text/javascript">
function OpenOutlookDoc(){
try {
var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.add('IPM.Note.FormA');
mailItem.Subject="a subject test";
mailItem.To = "[email protected]";
mailItem.HTMLBody = "<b>bold</b>";
mailItem.display (0);
}
catch(e){
alert(e);
// act on any error that you get
}
}
</script>
</head>
<body>
<a href="javascript:OpenOutlookDoc()">Click</a>
</body>
</html>
Solution 5
The specification for 'mailto' body says:
The body of a message is simply lines of US-ASCII characters. The only two limitations on the body are as follows:
- CR and LF MUST only occur together as CRLF; they MUST NOT appear independently in the body.
- Lines of characters in the body MUST be limited to 998 characters, and SHOULD be limited to 78 characters, excluding the CRLF.
https://www.rfc-editor.org/rfc/rfc5322#section-2.3
Generally nowadays most email clients are good at autolinking, but not all do, due to security concerns. You can likely find some work-arounds, but it won't necessarily work universally.
Rana Hossain
Just another programmer. I am currently working in C#.
Updated on July 24, 2022Comments
-
Rana Hossain almost 2 years
I have not had to mess with mailto links much. However I now need to add a link in the body of a mailto if it is possible.
Is there a way to add a link or to change the email opened to an html email vs a text email?
Something like:
<a href="mailto:[email protected]?body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.%0A%0ALink goes here">Link text goes here</a>
-
Amir-Mousavi almost 5 yearsit is really interesting, 10 years later people marked this question as a duplicate of another question which been asked 3 years later :))) Why? even that question's answers are no different and there has been no update to
RFC 2368
standard
-
-
Andrew Ferrier almost 12 yearsSafari on iOS renders tags such as <b>, <i>, and <img>. Not sure about <a>.
-
Rodney Hickman over 11 yearsI just tried your example and I get the error: "ReferenceError: ActiveXObject is not defined"
-
Rodney Hickman over 11 yearsI found that ActiveXObject is supported in Internet Explorer only, not in Metro style applications. Thanks anyway.
-
Harshit Tailor almost 11 yearsI tried your example...not working....
-
pmarreck over 6 yearsThis solution only works in a dystopian future world where Microsoft runs everything and Internet Exploiter is still making web developers' lives miserable.
-
Lars Juel Jensen about 6 yearsWorks with Mail app on MacOS and iOS, and with GMail on Chrome on MacOS and with the Mail app on iOS.
-
Pedro Araujo Jorge almost 6 yearsI can confirm that Thunderbird on Windows renders an url as a link (to the receiver), so there is no need to add any <a> tags.