138

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>
1
  • 5
    it 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 May 15, 2019 at 14:54

7 Answers 7

132

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.

3
  • Safari on iOS renders tags such as <b>, <i>, and <img>. Not sure about <a>. May 17, 2012 at 14:39
  • 1
    I 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. Jun 7, 2018 at 9:29
  • does outlook understands it, too? Nov 22 at 17:14
36

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>
1
  • Works with Mail app on MacOS and iOS, and with GMail on Chrome on MacOS and with the Mail app on iOS. Mar 5, 2018 at 16:35
8

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.

0
7

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>
3
  • 1
    I just tried your example and I get the error: "ReferenceError: ActiveXObject is not defined" Aug 15, 2012 at 17:11
  • 3
    I found that ActiveXObject is supported in Internet Explorer only, not in Metro style applications. Thanks anyway. Aug 15, 2012 at 17:13
  • 11
    This solution only works in a dystopian future world where Microsoft runs everything and Internet Exploiter is still making web developers' lives miserable.
    – pmarreck
    Dec 6, 2017 at 20:37
2

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.

1

Here's what I put together. It works on the select mobile device I needed it for, but I'm not sure how universal the solution is

<a href="mailto:[email protected]?subject=Me&body=%3Chtml%20xmlns%3D%22http:%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%3E%3C%2Fhead%3E%3Cbody%3EPlease%20%3Ca%20href%3D%22http:%2F%2Fwww.w3.org%22%3Eclick%3C%2Fa%3E%20me%3C%2Fbody%3E%3C%2Fhtml%3E">
1
  • 4
    I tried your example...not working.... Jul 12, 2013 at 7:04
1

I have implement following it working for iOS devices but failed on android devices

<a  href="mailto:?subject=Your mate might be interested...&body=<div style='padding: 0;'><div style='padding: 0;'><p>I found this on the site I think you might find it interesting.  <a href='@(Request.Url.ToString())' >Click here </a></p></div></div>">Share This</a>

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