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

Jiew Meng picture Jiew Meng · Jan 24, 2011 · Viewed 894.5k times · Source

Is it possible to set the subject/content of email when I use mailto:?

Answer

Haim Evgi picture Haim Evgi · Jan 24, 2011

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

mailto subject example:

<a href="mailto:[email protected]?subject=free chocolate">example</a>

mailto with content:

<a href="mailto:[email protected]?subject=look at this website&body=Hi,I found this website and thought you might like it http://www.geocities.com/wowhtml/">tell a friend</a>

As alluded to in the comments, both subject and body must be escaped properly. Use encodeURIComponent(subject) on each, rather than hand-coding for specific cases.

As Hoody mentioned in the comments, you can add line breaks by adding the following encoded sequence in the string:

%0D%0A // one line break