Mailto Link With HTML Body

mailto link with HTML body

As you can see in RFC 6068, this is not possible at all:

The special <hfname> "body" indicates that the associated <hfvalue>
is the body of the message. The "body" field value is intended to
contain the content for the first text/plain body part of the
message. The "body" pseudo header field is primarily intended for
the generation of short text messages for automatic processing (such
as "subscribe" messages for mailing lists), not for general MIME
bodies.

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

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.

\n doesn't work in the body value of a mailto: link

Use %0D%0A in place of \n, due to url encoding. %0D is the url encoding for Carriage Return, %0A is the url encoding for Line Feed.

Here's an answer that explains what each mean.

In your example, it'll come out like this:

<a href="mailto:example@example.com&subject=test&body=test%0D%0Atest%0D%0Atest%0D%0A">mail</a>

Also note that subject should be all lowercase, otherwise you'll end up with Subject=test as the subject itself.

mailto link using computed property not loading full message body

You must URL-encode your data before assigning it to the HREF property of a hyperlink/anchor tag:

mailToString()
{
return "mailto:" + encodeURIComponent(this.formData.emailList) + "?subject=" + encodeURIComponent(this.formData.subject) + "&body=" + encodeURIComponent(this.emailContent);
},

Otherwise it might interfer with some reserved characters, e.g. ? or = or & or some Unicode character.

Mailto link that contains a link within the email body?

You just can't use HTML in the mailto: function.

One other way to put a working link : use the PHP function mail() and write your link in html.

Mailto: Body formatting

Use %0D%0A for a line break in your body

  • How to enter line break into mailto body command (by Christian Petters; 01 Apr 2008)

Example (Demo):

<a href="mailto:someone@example.com?subject=Suggestions&body=name:%0D%0Aemail:">test</a>​
^^^^^^

Jquery Alternative to mailto link with html body

To open an email programmatically you can use window.location.assign with a mailto: link:

window.location.assign('mailto:test@test.com');

Pass your parameters as query string like you did:

window.location.assign('mailto:test@test.com?subject=test&body=testBody');

Passing HTML to the body is not possible as seen here: MailTo with HTML body

Can I set subject/content of email using mailto:?

Yes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm

mailto subject example: