email message in javascript


I have a problem with a small piece of JavaScript that is meant to set up an email message from clicking a link.  My problem is that I can't seem to put blank lines in an email message.

In my HTML I have something like this:
  <a href="javascript:mailpage()">Click here to email</a>

In the mailpage function, I have something like this:

mailpage() {
  mail_str = "mailto:?subject= the email subject";
  mail_str += "&body=   Line 1.";
  mail_str += "Line 2.";
  location.href = mail_str;

My problem is that I can't seem to set up the email message so that there will be a blank line between Line 1 and Line 2 in the message body.  So the message body of the email should be like this:


I've tried "\n\r", and also "\012\015", which have no effect at all.  Can anybody help me with this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can only do this one way. Take the contents of a textarea field and pass them as the body.

Read this article for more information:

In the end, it has nothing to do with what you are doing. E-mail programs will only accept a limited amount of data from the client browser. If you want to do this correctly, I would allow the user to send an e-mail via a form and use CGI to process it.
The \f escape character for line feed will work.

mailpage() {
 mail_str = "mailto:?subject= the email subject";
 mail_str += "&body=   Line 1.";
 mail_str += "\fLine 2.";
 location.href = mail_str;

Good Luck!

Since nobody has mentioned it, I will.

Mailto is inherently FLAKEY. Whatever you do, it's possible that it may not work. Even if it's RIGHT, it might not work.

Mailto relies TOTALLY on the client. Have a web mail client? Won't work. Have a proprietary client? Won't work. Have an older browser? Won't work. Have security settings high? Won't work. User doesn't send the mail? Won't work.

You may get an attachment with the querystring, nothing, a decent email, a blank mail -- and you have NO control over it.

If you REALLY want this to work, use a server side script. Chances are your ISP/hosting company has a form handler you can use. Find out and use it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I agree with webwoman, and to clarify her point further, I use Outlook Express 6 and the \f escape does not work for me.
djschickAuthor Commented:
Thanks for the info everybody!  Unfortunately the suggestions that people here didn't work for me, so I had to choose the best explanation why.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.