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:
<a href="mailto:no-one@snai1mai1.com?subject=free chocolate">example</a>
Related Topics
How to Remove All Script Tags from HTML File
Make Content Horizontally Scroll Inside a Div
Fixed Position Relative to Parent Container
How to Prevent Desktop Browser (Chrome, Safari) from Zooming a Webpage
How to Remove the Extra Space in in This Search Box (Between Input Field and Button)
How to Disable a Text Area or Mat-Form-Field
How to Do a Post Request in HTML Without Opening a New Tab
Limit the Size of a File Upload (Html Input Element)
How to Remove Free Spaces Between Divs
Selecting an Option in a Dropdown List Using Request Parameters
Having Difficulty Understanding How to Remove Some Padding
How to Remove the Default Arrow Icon from a Dropdown List (Select Element)
How to Make Flex Box Work in Safari
Table With Fixed Header and Fixed Column on Pure CSS
≪Meta Charset="Utf-8"≫ VS ≪Meta Http-Equiv="Content-Type"≫
Why Doesn't Percentage Padding/Margin Work on Flex Items in Firefox and Edge