473,238 Members | 1,765 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,238 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 4996
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.