473,739 Members | 6,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Carriage Return Email Body

TJO
I am trying to pre populate an email body using javascript. I cannot figure
out how to control the carraige returns for the text. The standard \r\n is
not working. Is there another technique I can try?
Jul 23 '05 #1
16 9537
TJO wrote:
I am trying to pre populate an email body using javascript.
Give up now and save yourself a lot of grief.
I cannot figure out how to control the carraige returns for
the text. The standard \r\n is not working.
Nope, that doesn't work.
Is there another technique I can try?


Submit a form, let the server send the email

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #2
TJO wrote:
I am trying to pre populate an email body using javascript. I cannot figure
out how to control the carraige returns for the text. The standard \r\n is
not working. Is there another technique I can try?


Randy is trying to say that this is very unreliable, as the user may
not have an email client configured, or it may not support all the
features of mailto.

For example, Lotus Notes will not accept a body of more than 200
characters, so whilst you may get away with this on a controlled
intranet, you should not use it on the web.

The following works with Lotus Notes based on the principle of escaping
the text (%0A is a return):

<a href='mailto:ro *@myemail.com?S UBJECT=E-mail with broken
lines&body=Here %20is%20a%20lin e%20with%0Aa%20 break'>Click
here to send...</a>

An alternative using \n and the escape function (you can use \r too if
that suits better):

<a href='' onclick="
this.href='mail to:ro*@myemail. com?SUBJECT=E-mailform&body='
+ escape('This is\na broken\nline');
">Click here to send...</a>

As noted, only lightly tested and certainly not considered suitable for
the web for the stated reasons.

Cheers, Rob.
Jul 23 '05 #3
RobG wrote:
[...]

<a href='' onclick="
this.href='mail to:ro*@myemail. com?SUBJECT=E-mailform&body='
+ escape('This is\na broken\nline');
">Click here to send...</a>


You can make that marginally more reliable in case JavaScript isn't
working by putting a useful href that *may* work regardless of
whether JavaScript is enabled:

<a href='mailto:ro *@myemail.com?S UBJECT=E-mailform&body=H i'
onclick="
this.href='mail to:ro*@myemail. com?SUBJECT=E-mailform&body='
+ escape('This is\na broken\nline');
">Click here to send...</a>

Using an onclick means you can get the content from a textarea or
similar too.

But it may still fail for the reasons Rob stated, and making it rely on
both JavaScript and mailto is kinda double jeopardy

Fred.
Jul 23 '05 #4
TJO wrote on 23 nov 2004 in comp.lang.javas cript:
I am trying to pre populate an email body using javascript.


Sure you can do that with serverside javascript.

But my guess is that you mean clientside in a browser.

Since the browsers in this world don't have a standard email client
connected, the only and very unreliable way is to use "mailto:' linking.

Advice: don't!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #5
TJO
Well boys and girls. I used the following script and tag
combo and I have not seen it not work yet.

Here is the tag:
<script type="text/javascript" language="JavaS cript"
src="mailtosupp ort.js"></script>

This is the content of the mailtosupport.j s file:
<!-- Begin
sendto = "my*****@atbigc ompany.com";
subject = "Support Request";
lf = escape('\r');
tab = escape('\t')

body = "Thank you for taking the time to notify us with an issue." + lf +
lf;
body += "If you have found an error in our system, please, to the best of
your ability answer the following questions." + lf + lf;
body += "Otherwise simply erase the following content and write you own.";
body += lf + lf + lf;
body += "1)" + tab + "Please describe the error, issue, or request:" + lf +
lf + lf;
body += "2)" + tab + "Please describe the time of day the issue occurred:" +
lf + tab + " The current Time is: " + Date() + lf + lf + lf;
body += "3)" + tab + "Please describe what you expected to occur:" + lf + lf
+ lf + lf;
document.write(
'<a href=\"mailto:'
+ sendto
+ '?subject='
+ subject
+ '&body='
+ body
+ '\">');
document.write( 'Email Support'+'</a>');
End -->


"TJO" <no@spam.net> wrote in message
news:Sauod.1264 19$cJ3.54345@fe d1read06...
I am trying to pre populate an email body using javascript. I cannot
figure out how to control the carraige returns for the text. The standard
\r\n is not working. Is there another technique I can try?

Jul 23 '05 #6
In article <wsKod.168785$h j.138021@fed1re ad07>, no@spam.net says...
"TJO" <no@spam.net> wrote in message
news:Sauod.1264 19$cJ3.54345@fe d1read06...
I am trying to pre populate an email body using javascript. I cannot
figure out how to control the carraige returns for the text. The standard
\r\n is not working. Is there another technique I can try?
Well boys and girls. I used the following script and tag
combo and I have not seen it not work yet.


Of course you haven't seen it fail, dummy. How many of your visitors
have, though, and have pushed off to another site that uses a reliable,
grown-up, way of handling form to email data?

Brilliant attitude - it works for me so it must work for everyone else.

--
Hywel
Jul 23 '05 #7
TJO wrote:
Well boys and girls. I used the following script and tag
combo and I have not seen it not work yet.
And you never will see it not work because you will never receive E-mail from
people on whose computers it does not work. This is a classic case of seeing the
result you expect. "It works for everyone who has sent me an E-mail!". Well,
yes, for those people who have sent you an E-mail, it did work.
document.write(
'<a href=\"mailto:'
+ sendto
+ '?subject='
+ subject
+ '&body='
+ body
+ '\">');
document.write( 'Email Support'+'</a>');
End -->


That last line is just wrong. If you insist on using HTML comments, you should
comment them out in JavaScript so as not to cause a syntax error:

// End -->

However, HTML comments inside <script></script> tags can be removed entirely.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #8
On Tue, 23 Nov 2004 18:53:49 -0000, Hywel Jenkins
<hy**********@h otmail.com> wrote:

[snip]
Of course you haven't seen [the mailto: script] fail, dummy. How many
of your visitors have, though, and have pushed off to another site that
uses a reliable, grown-up, way of handling form to email data?

Brilliant attitude - it works for me so it must work for everyone else.


I am always perplexed by that line of thinking.

"No-one's e-mailed me to tell me that my mail system doesn't work
for them."

Really? I wonder why.

Good grief...

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #9
TJO
Well Hywink,
I have tested in on other browsers and have not seen it not work on any. If
you can or others can tell me where it won't work then that is what I was
looking for.
Otherwise it appears to be valid solution.
"Hywel Jenkins" <hy**********@h otmail.com> wrote in message
news:MP******** *************** @news.individua l.net...
In article <wsKod.168785$h j.138021@fed1re ad07>, no@spam.net says...
"TJO" <no@spam.net> wrote in message
news:Sauod.1264 19$cJ3.54345@fe d1read06...
>I am trying to pre populate an email body using javascript. I cannot
>figure out how to control the carraige returns for the text. The
>standard
>\r\n is not working. Is there another technique I can try?
>

Well boys and girls. I used the following script and tag
combo and I have not seen it not work yet.


Of course you haven't seen it fail, dummy. How many of your visitors
have, though, and have pushed off to another site that uses a reliable,
grown-up, way of handling form to email data?

Brilliant attitude - it works for me so it must work for everyone else.

--
Hywel

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
31345
by: | last post by:
Hi, I want to send an Email using ASP (I know how to to this) The body of the Email contains several variabels How do I concat string values and separate them by carriage returns/ Line feeds? Any help will be greatly appreciate. Regards,
3
1792
by: Guy Verville | last post by:
I'm perplexed, I have several forms that seem to be ok, but what is sent by email doesn't contain all the Carriage returns sent. The form contains many fields and is sent as follow:...
4
7316
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to use: 'replace carriage returns with BRs comment=Replace(comment, chr(13), "<br>") but obviously net.! The <pre> tag doesn't sem to help either as the embedded return is
3
2418
by: Dave Tichenor | last post by:
How do you create a new line in the mail message; i'm using asp.net. I try using - vbcrlf - chr(13) and chr(10) - Environment.NewLine But when i receive the email message it is concatenated all together. thanks
2
40023
by: sean | last post by:
Can anyone tell me how to add a carriage return to a string using vb.net? I need to add two strings with a carrage return together and post to an email message body ie: This gives me an error: string3 = string1 & vbcrlf & string2 mail.body = string3
5
6619
by: kplkumar | last post by:
I have an email message and the body of that message has to be formatted in a certain way. Currently it's Patient Name: XXX Patient Address: 87 XXXX Country: XXX but I want to have carriage return after each field. For example, Patient Name: XXX Patient Address: 87 XXXX Country: XXX
1
3638
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi, I'm using the following code to send an email and it's working OK but using \r\n is not breaking up the lines and I tried Convert.ToChar(10) also and still it doesn't carriage retun. MailMessage objMailMsg = new MailMessage(strFrom, strTo);
2
4605
by: inx3us | last post by:
My simple code to send Form fields to Outlook: Dim strMsgBody As String Dim strSubject As String strSubject = "Subject is here" strMsgBody = "Body." " COMPANY NAME: " + Text82 & " CUSTOMER NUMBER: " & Text5 & " P/W: " & Text80 & "CONTACT" & Text3 & "EMAIL" & Text13 & "CONTACT2" & Text19 & "EMAIL" & Text21 & "CONTACT3" & Text22 & "EMAIL" & Text15 DoCmd.SendObject , , , , , , strSubject, strMsgBody
11
12598
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message so the user can edit the default email message body before sending the message. But when I populate the large text box (txtBody), I can't get it to include the carriage returns. I've tried vbNewLine, vbCrLf, Chr(10) and Chr(13). I've got the...
0
8969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6054
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.