I would like to insert a line break into my mailto body. I tried %0A, %0D and %0D%0A. Nothing worked for me. I tested on Gmail, Yahoo, Apple Mail, Outlook 2010, Outlook.com and Thunderbird with Google Chrome on Mac OSX.
Any help please ?
Here's my code :
<a href="mailto:[email protected]?subject=Subscribe&body=Lastame%20%3A%0D%0A%20Firstname%20%3A"><img alt="Subscribe" class="center" height="50" src="subscribe.png" style="width: 137px; height: 50px; color: #4da6f7; font-size: 20px; display: block;" width="137"></a>
Curiously in gmail for android %0D%0A
doesn't work and <br>
works:
<a href="mailto:[email protected]?subject=This%20is%20Subject&body=First line<br>Second line">
click here to mail me
</a>
<a href="mailto:[email protected]?subject=Request&body=Hi,%0DName:[your name] %0DGood day " target="_blank"></a>
Try adding %0D to break the line. This will definitely work.
Above code will display the following:
Hi,
Name:[your name]
Good day
For plaintext email using JavaScript, you may also use \r
with encodeURIComponent()
.
For example, this message:
hello\rthis answer is now well formated\rand it contains good knowleadge\rthat is why I am up voting
URI Encoded, results in:
hello%0Dthis%20answer%20is%20now%20well%20formated%0Dand%20it%20contains%20good%20knowleadge%0Dthat%20is%20why%20I%20am%20up%20voting
And, using the href:
mailto:[email protected]?body=hello%0Dthis%20answer%20is%20now%20well%20formated%0Dand%20it%20contains%20good%20knowleadge%0Dthat%20is%20why%20I%20am%20up%20voting
Will result in the following email body text:
hello
this answer is now well formated
and it contains good knowleadge
that is why I am up voting
For the Single line and double line break here are the following codes.
Single break: %0D0A
Double break: %0D0A%0D0A
Source: Stackoverflow.com