Reputation: 235
I have an application which displays a list of users , When clicking on the email button I want the email client to open up with a prepopulated message ( I make the message using javascript) , I am not sure about how to prepopulate the message
Any help would be appreciated
I would post snippets , but honestly I dnt know how to start with this
Upvotes: 2
Views: 1939
Reputation: 32608
URI encode the text and then append it to a mailto:
URL:
<a href='mailto:[email protected]?body=text%20here'>Send mail!</a>
More generally, you can use:
body
parameters will put each on a new line)with an ampersand (&) between each pair.
mailto:[email protected]?subject=Hi&body=some%20text
Upvotes: 8
Reputation: 140244
You can use jQuery to find all the links that have mailto:
, then process their href to add the message body:
$("a[href^='mailto:']").prop( "href", function(i, prop){
return prop + "?body=" + encodeURIComponent( "Your message here" );
});
Demo:
Upvotes: 2