October 23, 2000 - Adding New Lines to A mailto: URL | WebReference

October 23, 2000 - Adding New Lines to A mailto: URL

Yehuda Shiran October 23, 2000
Adding New Lines to A mailto: URL
Tips: October 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

The mailto: URL lets you specify a full mail message. For example, the following HTML code:

<A HREF="mailto:tomer@netscent.com?cc=yehuda@internet.com&
bcc=tomer@internet.com&subject=Your Tips">Your Feedback is Always Appreciated.</A>

creates the following link: Your Feedback is Always Appreciated. Try it out.

But what if you want to have paragraphs in your mail message. How do you add new lines to the body? The answer is: hexadecimal. All but alphanumeric characters should be converted to hexadecimal representation, using the escape() method. Even better, you can use our Mailtool to enter all the mail message fields. Try composing a message of your own. Add some new lines in the body's text area. Click the Create URL button, and examine the output URL. You can see that each new line is converted into %0D%0A. This is the Carriage Return (%0D) and Line Feed (%0A) that are inserted into the page when you hit the Enter key. So now you know what to do when you need to add a new line. Just add "%0D%0A", or even better, use the Mailtool.

Learn more about the mailto: URL in Column 70, The Mailtool.