Friday, November 06, 2015

How-To: Create a Mailto: link with a subject and body text

Have you ever wondered how to make a really awesome MailTo: link that populates the subject line AND the body text with JUST ONE CLICK?


The trick is to use the "Subject" and "Body"+ Percent Encoding Reserved Characters

Specifically a newline character %0D also know as a Carriage Line or CR but you can get creative and use any of the others. The trick is to leave no white space.

Percent Encoding Reserved  Characters - Taken from Wikipedia

Here's and example:


Paste this code below into the W3 Schools Tryit Editor

FYI: I generated code text with http://hilite.me/

<a href="mailto:toexample@example.com?cc=ccexample@example.com&bcc=bccexample@example.com&subject=Subject%20Goes%20-%20Here&body=Body%20Greeting,%0D%0DPut%20second%20line%20here%0D%0D%0D%0D"%20target="_top">Send mail!</a>


If you removed all the white spaces correctly. It will generate an email like this. 

Note: I have added two "%0D%0D%0D%0D" at the end so when the person replying to the email clicks on the body text they will start two lines down. :)




Have fun playing!

Luke