How can I include a multi-line message in a mailto: URL?
Created May 4, 2012
Jayesh Nazre Well you have to pass the parameter "body" a value.
To embed your message completely in your HTML page, you'll need to use JavaScript's escape() method to convert the text with new lines to something that can be used in a mailto URL.
<html> <head> <script language=javascript> function send() { var lstr_data = "FIRST LINE" + " " + "SECOND LINE" + " " + "THIRD LINE"; window.location.href="mailto:jayesh_nazre@hotmail.com" + "?body=" + escape (lstr_data); } </script> </head> <body> <a href="javascript:send();">Send Message</a> </body> </html>
Instead, you can get the message from a TextArea on the page...
<html> <head> <script language=javascript> function send() { window.location.href="mailto:jayesh_nazre@hotmail.com" + "?body=" + document.frm_test.ta_body.value; } </script> </head> <body> <form id=frm_test name=frm_test> Mail Contents:Note if you need to specify the subject then u need to pass the parameter "subject" like this
<TEXTAREA NAME=ta_body ROWS="6" COLS="55"> HELLO1 HELLO2 </TEXTAREA> <input type=button value=SendMail onclick=send()> </form> </body> </html>
window.location.href="mailto:jayesh_nazre@hotmail.com" + "?subject=" + "TEST MAIL";