473,408 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

mailto line break question

5
Hi All,
Great site BTW!
OK, I'm very new at this so forgive me ignorance, please!

I have a little JS that emails elements from a form; name, choice from a drop-down list, and "comments". It all works fine except that when it dumps the results into the body of the email, there are no line breaks.
I tried adding + "\r" and "\n" with no improvement. I'm guess the script is sending plain text at this point. Is there any way to embed an ascii code for carriage return in the + "" section of this code?

Expand|Select|Wrap|Line Numbers
  1. function SendEmail()
  2. {
  3.     var dept = 'department';
  4.     var toaddy = 'X@xxx.com';
  5.     var subject = 'Contact Us Reply';
  6.     var mailer = 'mailto:' + toaddy + '?subject=' + subject + '&body=' + 
  7. 'Name%20is:%20' +  document.jsform.visitorname.value  + "" +
  8. 'Request%20is:%20' + document.jsform.department.value + "" +
  9. 'Comments%20are:%20\n' + document.jsform.message.value + "" ;
  10.     parent.location = mailer; 
  11. } // -->
  12.  
  13.  
Thanks.
--MK
PS I'm in a MacOS environment and I'm testing this in MacMail.
Oct 5 '08 #1
8 5009
did you try "/n/r" ?
"/n" creates a new line, but you need "/r" to come after it to move your point of refence to the new line
Oct 5 '08 #2
mkalex
5
Thanks, zaphod42

I did try "/n/r" or rather "\n\r" with no result.

--MK
Oct 6 '08 #3
acoder
16,027 Expert Mod 8TB
I wouldn't recommend mailto unless there's no alternative. Is it not possible to use a server-side language?
Oct 6 '08 #4
mkalex
5
Thanks for the reply Acoder,

You are of course correct, a server side mailer would be better; yet my curiosity is piqued. If I get an answer here on this forum, I will have abetter understanding of javascript.

--MK
Oct 6 '08 #5
mkalex
5
Never mind...

I solved my problem with "\u2029"
It allows me to add a paragraph anywhere I need.

Thanks, though

--MK
Oct 6 '08 #6
acoder
16,027 Expert Mod 8TB
Good job. If you escape the line break, you could probably use it in your code, though I haven't tested, e.g. by using encodeURIComponent(), or using String.fromCharCode(10) and 13.
Oct 6 '08 #7
improvcornartist
303 Expert 100+
Can you use %0A? It is the URL encoded linefeed.
Oct 6 '08 #8
acoder
16,027 Expert Mod 8TB
That makes sense, and that is indeed what encodeURIComponent("\n") produces. If you want a carriage return too, add %0D
Oct 6 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: nAmYzArC | last post by:
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 ...
19
by: Philipp Lenssen | last post by:
I don't know the English word, but I'm referring to the double-dash which is used to separate parts of a sentence. I'm using — so far. Now I saw – which is slightly shorter. Some sites use --. ...
15
by: Val | last post by:
Any experts on mailto: tags? I want to set a link so that the subject and some of the body of the email is filled in. This is easy for simple text, although you need to use %20 for spaces: <a...
9
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
5
by: Joh | last post by:
I'm using mailto to open up an email that have a hyperlink in the body. The hyperlink passes two variables Name and Emailadress. The problem is that only the first variable Name show up in the...
10
by: Itaichuk | last post by:
Hi I read in several CSS tutorials that block-level elements, such as <div& <pare rendered with an implicit line break before and after. I set to test this out using the following HTML: I...
3
by: fiefie.niles | last post by:
Either in ASP or VB using Internet Explorer, how can I do a mailto where the body has a link, and the link has a T=5&S=2 like the following? mailto:fiefie.niles@gmail.com?subject=Help Desk...
6
by: Mike | last post by:
I have to use mailto so the pages opens up the users default client. I need to format the body of the email in HTML format so I can show some the text in bold, italics and underlined? Is this...
2
by: GArlington | last post by:
"G. Morgan" <no_em@il.invalidwrote in message news:8787770faf30b1bd48f393baa1a89fdbnp@mypost.invalid... <snap> <snap> Did you try <cr><lf combination? ** Posted from http://www.teranews.com...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.