32

<a href="mailto:[email protected]?subject=Whatever%20this%20is &body=HowcanIaddLine<br/>Break here

I wonder if it is possible to write something like %20 (which stands for a space) for a line-break as well. So I want to have separate lines in my body of the e-mail.

Any ideas?

3
  • Try %0A. That's the ASCII code for a newline. Commented Feb 22, 2013 at 8:20
  • However, I don't think it's possible to add linebreaks to a mail subject Commented Feb 22, 2013 at 8:23
  • Does this answer your question? Insert a line break in mailto body
    – jtbandes
    Commented Sep 7, 2020 at 19:31

2 Answers 2

41

You should use a carriage return %0D and line feed %0A

<a href="mailto:[email protected][email protected]&subject=your subject&body=Text before new line.%0D%0AText after new line.">create email</a>

This is defined in RFC2368 and is the only valid method of generating a line-break.

3
  • 3
    This doesn't seem to work for gmail.com and its mobile app. Is there anything special that needs to be done for gmail to make the line break work?
    – Jason O.
    Commented Aug 15, 2015 at 23:22
  • @JasonO. in gmail for Android you can use my answer Commented Apr 13, 2020 at 12:14
  • That's a curious choice to enforce Windows-style line breaks over Unix-style. I wonder what the history behind that is
    – Post Self
    Commented Jun 30, 2022 at 23:24
7

Replace \n (and \r\n) by %0D%0A as specified by RFC6068 (in section 5) updating the mailto URI Scheme as of October 2010 (replacing RFC2368).

[...] line breaks in the body of a message MUST be encoded with "%0D%0A".
Implementations MAY add a final line break to the body of a message even if there is no trailing "%0D%0A" in the body [...]

This is the example from the RFC (in section 6)

<mailto:[email protected]?body=send%20current-issue%0D%0Asend%20index>

The above mail body corresponds to:

send current-issue
send index

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.