472,142 Members | 1,244 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

adding linebreak in mailto body

Hi everyone,

I'm setting the body of an email using values from a form

firstname = bob
lastname = dole

ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname

window.location.href = 'mailto:my*****@mycompany.com?subject=test
email&body=' + ebody;

If I do an "alert(ebody);" I get the linebreak between firstname &
lastname, however when it opens up outlook, the entire ebody string
appears without a linebreak in the email body.

I've tried just \n also. is there something that can give be a line
break?
Jul 20 '05 #1
15 24563
In article <f7**************************@posting.google.com >,
st**************@hotmail.com (nAmYzArC) writes:
Hi everyone,

I'm setting the body of an email using values from a form


http://www.allmyfaqs.com/faq.pl?Email_form_data

http://www.isolani.co.uk/articles/mailto.html

If you want to reliably send email, send it from the server.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #2
> If you want to reliably send email, send it from the server.

This is not a requirement stated in my original question. I am well
aware of the advantages of sending email server-side. But thanks for
the input anyway.
Jul 20 '05 #3
In article <f7**************************@posting.google.com >,
st**************@hotmail.com says...
If you want to reliably send email, send it from the server.


This is not a requirement stated in my original question. I am well
aware of the advantages of sending email server-side. But thanks for
the input anyway.

Well using mailto to GENERATE a message is bogus to say the least and only
amateurs do it.

My suggestion would be to either...

1. Let the user CREATE the body and don't worry about adding any CR/LF
2. Use an some server component such as ASPMail to do it for you.

Jul 20 '05 #4
In article <f7**************************@posting.google.com >,
st**************@hotmail.com (nAmYzArC) writes:
If you want to reliably send email, send it from the server.


This is not a requirement stated in my original question. I am well
aware of the advantages of sending email server-side. But thanks for
the input anyway.


Then one can safely assume that you are aware that your approach to trying to
send it client-side is very flawed? If its an intranet environment, where you
know Outlook is the default email client, then you can approach it differently.
Short of that, if its a web-based approach, then you need to rethink your
approach.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #5
In article <f7**************************@posting.google.com >,
st**************@hotmail.com says...
Hi everyone,

I'm setting the body of an email using values from a form

firstname = bob
lastname = dole

ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname

window.location.href = 'mailto:my*****@mycompany.com?subject=test
email&body=' + ebody;

If I do an "alert(ebody);" I get the linebreak between firstname &
lastname, however when it opens up outlook, the entire ebody string
appears without a linebreak in the email body.

I've tried just \n also. is there something that can give be a line
break?

On another note...

Outlook doesn't understand \r\n means CR/LF...

Try using:

ebody = 'First Name: ' + fromCharCode(10) + fromCharCode(13) +
'Last Name: ' + lastname;
instead.
Jul 20 '05 #6
rh
"Vjekoslav Begovic" <vj*******@inet.hr> wrote in message news:<bh**********@sunce.iskon.hr>...
<snip>

It's an HTML issue. Put: ebody = 'First Name: ' + firstname + '%0D' + 'Last
Name: ' + lastname
You may also want to check this article:
http://www.itworld.com/nl/html_tutor/03122002/


That article appears to have dropped a character in describing the
escape sequence for \r\n -- it has "%0D%0" where "%0D%0A" was
apparently intended.

Since Javascript provides an "escape" function, would it not be
preferable to simply escape the text, and avoid the special code
arcana?

../rh
Jul 20 '05 #7
Hi,

Vjekoslav Begovic wrote:
"nAmYzArC" <st**************@hotmail.com> wrote in message
news:f7**************************@posting.google.c om...
Hi everyone,

I'm setting the body of an email using values from a form

firstname = bob
lastname = dole

ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname

window.location.href = 'mailto:my*****@mycompany.com?subject=test
email&body=' + ebody;

If I do an "alert(ebody);" I get the linebreak between firstname &
lastname, however when it opens up outlook, the entire ebody string
appears without a linebreak in the email body.

I've tried just \n also. is there something that can give be a line
break?

It's an HTML issue. Put: ebody = 'First Name: ' + firstname + '%0D' + 'Last
Name: ' + lastname
You may also want to check this article:
http://www.itworld.com/nl/html_tutor/03122002/


I can not believe that you, in a technical newsgroup, post a link to an
article praising a technique so deeply flawed that using it is like
throwing a stone in a well and hoping to receive an answer by email.

If the well is inhabited by a dwarf who happens to have an internet
connection, and that by chance your email address is written on the
stone, you might actually receive an email back. Using mailto: as
described in this "article" has approximately the same amount of chances
to work like you expect it.

It cannot be stressed enough: Using mailto with anything else than an
email address doesn't work reliably enough that it's worth even
mentioning it. Just forget it, it doesn't work. What's worse is: When it
doesn't work, you cannot have any feedback from your users, since they
cannot send you any email.

If you don't have any access to CGI (like the excellent, and free,
formmail for example), then use a free service provider, for example
Bravenet.

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #8
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:bi**********@rex.ip-plus.net...
I can not believe that you, in a technical newsgroup, post a link to an
article praising a technique so deeply flawed that using it is like
throwing a stone in a well and hoping to receive an answer by email.
That article describes the use of mailto link, and OP wants to use mailto
link. Why he wants to do that, that's not my problem.
If the well is inhabited by a dwarf who happens to have an internet
connection, and that by chance your email address is written on the
stone, you might actually receive an email back. Using mailto: as
described in this "article" has approximately the same amount of chances
to work like you expect it.

It cannot be stressed enough: Using mailto with anything else than an
email address doesn't work reliably enough that it's worth even
mentioning it. Just forget it, it doesn't work. What's worse is: When it
doesn't work, you cannot have any feedback from your users, since they
cannot send you any email.

If you don't have any access to CGI (like the excellent, and free,
formmail for example), then use a free service provider, for example
Bravenet.


OK, but OP asked <cite>is there something that can give be a line
break?</cite>.

Jul 20 '05 #9
Whoa people -
There seems to be alot of un-needed debate here.
Let me try to simplify things:

1) I AGREEE that using server site mailing is the way to go.

2) I have a REQUREMENT to use only .htm pages. (NO server-side
programming is allowed. A mailto link seemed to be the only logical
route given the requirements.)

3) My question was NOT "Server-side vs Client-side mail. pros/cons?".
It was:
"How do i add a LINEBREAK in a mailto body"

Honestly, I like seeng some healthy debate on subjects, but in this
case, when I came back to the thread the conversation amused me and
seemed somewhat like the following:

Me: "I need bananas. Where can I find a place near me that sells
bananas?"

Vjekoslav: "Down the street, to your right." - original question
ANSWERED!!!!

Everyone else: "Why not have an Apple instead? They have more vitamins
and less calories. Apples are the way to go. Also, fruit is not the
way to go. Veggies instead have no seeds yada yada.." - original
question remains unanswered, AND topic changes!!!

P.S. I am not a fruit/vegetable expert. I do not take any
responsibility for any adverse effects on anyone's health based on my
fruit & vegetable commentary. :)

"Vjekoslav Begovic" <vj*******@inet.hr> wrote in message news:<bi**********@sunce.iskon.hr>...
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:bi**********@rex.ip-plus.net...
I can not believe that you, in a technical newsgroup, post a link to an
article praising a technique so deeply flawed that using it is like
throwing a stone in a well and hoping to receive an answer by email.


That article describes the use of mailto link, and OP wants to use mailto
link. Why he wants to do that, that's not my problem.
If the well is inhabited by a dwarf who happens to have an internet
connection, and that by chance your email address is written on the
stone, you might actually receive an email back. Using mailto: as
described in this "article" has approximately the same amount of chances
to work like you expect it.

It cannot be stressed enough: Using mailto with anything else than an
email address doesn't work reliably enough that it's worth even
mentioning it. Just forget it, it doesn't work. What's worse is: When it
doesn't work, you cannot have any feedback from your users, since they
cannot send you any email.

If you don't have any access to CGI (like the excellent, and free,
formmail for example), then use a free service provider, for example
Bravenet.


OK, but OP asked <cite>is there something that can give be a line
break?</cite>.

Jul 20 '05 #10
actually a plain old '%0D' works great as a linebreak in outlook. That's all I need.

Mr. Clean <mr*****@protctorandgamble.com> wrote in message news:<MP************************@news-server.austin.rr.com>...
In article <f7**************************@posting.google.com >,
st**************@hotmail.com says...
Hi everyone,

I'm setting the body of an email using values from a form

firstname = bob
lastname = dole

ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname

window.location.href = 'mailto:my*****@mycompany.com?subject=test
email&body=' + ebody;

If I do an "alert(ebody);" I get the linebreak between firstname &
lastname, however when it opens up outlook, the entire ebody string
appears without a linebreak in the email body.

I've tried just \n also. is there something that can give be a line
break?

On another note...

Outlook doesn't understand \r\n means CR/LF...

Try using:

ebody = 'First Name: ' + fromCharCode(10) + fromCharCode(13) +
'Last Name: ' + lastname;
instead.

Jul 20 '05 #11
Hi.

nAmYzArC wrote:
Whoa people -
There seems to be alot of un-needed debate here.


<snip>

Sorry, but I disagree. You asked a question and you got an answer.
Having noticed that, I consider it my duty to give you some insights
about the bad solution that you choose to apply. Nothing in your first
post lets us know that you're not a total newbie, and god knows that we
see a lot of them around here. I consider that they deserve to get a
little knowledge.

A good way to avoid this kind of debate would have been to start your
post with "I am aware that mailto should never be used like I intend to
do, and yet I need to do it anyway".

We have only as much information as you give us. Don't complain when you
receive good quality answers adapted to the quantity of information you
gave.

I strongly believe that people who answer posts in a technical
newsgroups have a certain duty towards the people they answer to.
Pointing your misuse of mailto certainly is part of that.

Friendly,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #12
Mr. Clean <mr*****@protctorandgamble.com> wrote in message news:<MP************************@news-server.austin.rr.com>...
In article <f7**************************@posting.google.com >,
st**************@hotmail.com says...
Hi everyone,

I'm setting the body of an email using values from a form

firstname = bob
lastname = dole

ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname

window.location.href = 'mailto:my*****@mycompany.com?subject=test
email&body=' + ebody;

If I do an "alert(ebody);" I get the linebreak between firstname &
lastname, however when it opens up outlook, the entire ebody string
appears without a linebreak in the email body.

I've tried just \n also. is there something that can give be a line
break?

On another note...

Outlook doesn't understand \r\n means CR/LF...

Try using:

ebody = 'First Name: ' + fromCharCode(10) + fromCharCode(13) +
'Last Name: ' + lastname;
instead.


Actually using this gave me an 'object expected' error.
Jul 20 '05 #13
<SNIP>

On another note...

Outlook doesn't understand \r\n means CR/LF...

Try using:

ebody = 'First Name: ' + fromCharCode(10) + fromCharCode(13) +
'Last Name: ' + lastname;
instead.


Actually using this gave me an 'object expected' error.

Without seeing your complete code, I can't tell what would be causing that
because fromCharCode(10) should work just fine.
Jul 20 '05 #14
Mr. Clean <mr*****@protctorandgamble.com> writes:
Without seeing your complete code, I can't tell what would be causing that
because fromCharCode(10) should work just fine.


Shouldn't that be "String.fromCharCode(10)"?
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #15
In article <u1**********@hotpop.com>, lr*@hotpop.com says...
Mr. Clean <mr*****@protctorandgamble.com> writes:
Without seeing your complete code, I can't tell what would be causing that
because fromCharCode(10) should work just fine.


Shouldn't that be "String.fromCharCode(10)"?
/L

Whoa, you got me...Yes, that is right...
Jul 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by levi | last post: by
15 posts views Thread by Val | last post: by
2 posts views Thread by laredotornado | last post: by
2 posts views Thread by Luis Esteban Valencia Muñoz | last post: by
3 posts views Thread by Michael Hamm | last post: by
5 posts views Thread by Joh | last post: by
2 posts views Thread by Andrew Poulos | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.