Carriage Return Email Body

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TJO

    Carriage Return Email Body

    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 Webb

    #2
    Re: Carriage Return Email Body

    TJO wrote:
    [color=blue]
    > I am trying to pre populate an email body using javascript.[/color]

    Give up now and save yourself a lot of grief.
    [color=blue]
    > I cannot figure out how to control the carraige returns for
    > the text. The standard \r\n is not working.[/color]

    Nope, that doesn't work.
    [color=blue]
    > Is there another technique I can try?[/color]

    Submit a form, let the server send the email

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    • RobG

      #3
      Re: Carriage Return Email Body

      TJO wrote:[color=blue]
      > 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?[/color]

      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 b@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:rob@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.

      Comment

      • Fred Oz

        #4
        Re: Carriage Return Email Body

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

        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 b@myemail.com?S UBJECT=E-mailform&body=H i'
        onclick="
        this.href='mail to:rob@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.

        Comment

        • Evertjan.

          #5
          Re: Carriage Return Email Body

          TJO wrote on 23 nov 2004 in comp.lang.javas cript:
          [color=blue]
          > I am trying to pre populate an email body using javascript.[/color]

          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)

          Comment

          • TJO

            #6
            Re: Carriage Return Email Body

            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 = "myemail@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...[color=blue]
            >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?
            >[/color]


            Comment

            • Hywel Jenkins

              #7
              Re: Carriage Return Email Body

              In article <wsKod.168785$h j.138021@fed1re ad07>, no@spam.net says...[color=blue]
              > "TJO" <no@spam.net> wrote in message
              > news:Sauod.1264 19$cJ3.54345@fe d1read06...[color=green]
              > >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?
              > >[/color][/color]
              [color=blue]
              > Well boys and girls. I used the following script and tag
              > combo and I have not seen it not work yet.[/color]

              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

              Comment

              • Grant Wagner

                #8
                Re: Carriage Return Email Body

                TJO wrote:
                [color=blue]
                > Well boys and girls. I used the following script and tag
                > combo and I have not seen it not work yet.[/color]

                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.
                [color=blue]
                > document.write(
                > '<a href=\"mailto:'
                > + sendto
                > + '?subject='
                > + subject
                > + '&body='
                > + body
                > + '\">');
                > document.write( 'Email Support'+'</a>');
                > End -->[/color]

                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 <gwagner@agrico reunited.com>
                comp.lang.javas cript FAQ - http://jibbering.com/faq

                Comment

                • Michael Winter

                  #9
                  Re: Carriage Return Email Body

                  On Tue, 23 Nov 2004 18:53:49 -0000, Hywel Jenkins
                  <hyweljenkins@h otmail.com> wrote:

                  [snip]
                  [color=blue]
                  > 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.[/color]

                  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.

                  Comment

                  • TJO

                    #10
                    Re: Carriage Return Email Body

                    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" <hyweljenkins@h otmail.com> wrote in message
                    news:MPG.1c0d97 939163768989695 @news.individua l.net...[color=blue]
                    > In article <wsKod.168785$h j.138021@fed1re ad07>, no@spam.net says...[color=green]
                    >> "TJO" <no@spam.net> wrote in message
                    >> news:Sauod.1264 19$cJ3.54345@fe d1read06...[color=darkred]
                    >> >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?
                    >> >[/color][/color]
                    >[color=green]
                    >> Well boys and girls. I used the following script and tag
                    >> combo and I have not seen it not work yet.[/color]
                    >
                    > 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[/color]


                    Comment

                    • Hywel Jenkins

                      #11
                      Re: Carriage Return Email Body

                      In article <VIOod.127305$c J3.123019@fed1r ead06>, no@spam.net says...[color=blue]
                      > "Hywel Jenkins" <hyweljenkins@h otmail.com> wrote in message
                      > news:MPG.1c0d97 939163768989695 @news.individua l.net...[color=green]
                      > > In article <wsKod.168785$h j.138021@fed1re ad07>, no@spam.net says...[color=darkred]
                      > >> "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?
                      > >> >[/color]
                      > >[color=darkred]
                      > >> Well boys and girls. I used the following script and tag
                      > >> combo and I have not seen it not work yet.[/color]
                      > >
                      > > 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.[/color][/color]

                      [color=blue]
                      > Well Hywink,[/color]

                      I always know I'm dealing with an intellectual tosser when that sort of
                      thing creeps up.

                      [color=blue]
                      > I have tested in on other browsers and have not seen it not work on any.[/color]

                      Combinations?

                      [color=blue]
                      > If
                      > you can or others can tell me where it won't work then that is what I was
                      > looking for.[/color]

                      You were looking for a malformed URL? Something that can cause the
                      email to be sent as expected; the email to be sent blank; the email not
                      to be sent; the email client to crash; the OS to crash; is there an
                      email client on the visitor's computer? Think, boy, think.

                      [color=blue]
                      > Otherwise it appears to be valid solution.[/color]

                      It may appear to be whatever you want. A "valid solution", however, it
                      isn't.

                      --
                      Hywel

                      Comment

                      • Randy Webb

                        #12
                        Re: Carriage Return Email Body

                        TJO wrote:[color=blue]
                        > Well boys and girls. I used the following script and tag
                        > combo and I have not seen it not work yet.[/color]

                        Only because you have failed to test it properly.

                        It fails for me for my IE6 and default email client.
                        It fails for me for my Mozilla and default email client.

                        --
                        Randy
                        comp.lang.javas cript FAQ - http://jibbering.com/faq

                        Comment

                        • TJO

                          #13
                          Re: Carriage Return Email Body

                          What fails? What email client are you using??

                          Mine tested fine. Very curious.


                          "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                          news:ZsydnWAOlp pmaz7cRVn-3Q@comcast.com. ..[color=blue]
                          > TJO wrote:[color=green]
                          >> Well boys and girls. I used the following script and tag
                          >> combo and I have not seen it not work yet.[/color]
                          >
                          > Only because you have failed to test it properly.
                          >
                          > It fails for me for my IE6 and default email client.
                          > It fails for me for my Mozilla and default email client.
                          >
                          > --
                          > Randy
                          > comp.lang.javas cript FAQ - http://jibbering.com/faq[/color]


                          Comment

                          • TJO

                            #14
                            Re: Carriage Return Email Body

                            Who uses Lotus Notes anymore???

                            "RobG" <rgqld@iinet.ne t.auau> wrote in message
                            news:Lgwod.812$ I52.31670@news. optus.net.au...[color=blue]
                            > TJO wrote:[color=green]
                            >> 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?[/color]
                            >
                            > 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 b@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:rob@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.[/color]


                            Comment

                            • Randy Webb

                              #15
                              Re: Carriage Return Email Body

                              TJO wrote:[color=blue]
                              > What fails?[/color]

                              The link fails. What else?
                              [color=blue]
                              > What email client are you using??[/color]

                              My default/preferred email client when browsing the web is a web-based
                              Flash Form based email client through Comcast Cable.

                              Steps to compose mail:

                              Navigate to the comcast web site.
                              Navigate to the Email page.
                              Login via a Flash App that does not accept parameters (can't auto login).
                              Click Compose Mail.
                              Compose the Mail.

                              If you can create a link that does all that then you might have a
                              fool-proof script. Of course, its a simple matter of clicking "Submit"
                              to submit a form and send the email if its done the most reliable way -
                              a server side script.
                              [color=blue]
                              > Mine tested fine.[/color]

                              So do popups onload for people that don't have them disabled.
                              [color=blue]
                              > Very curious.[/color]

                              I am curious too. Can you define "top-posting" for me please? Its
                              explained in the group FAQ.

                              <--snip-->

                              --
                              Randy
                              comp.lang.javas cript FAQ - http://jibbering.com/faq
                              Answer:It destroys the order of the conversation
                              Question: Why?
                              Answer: Top-Posting.
                              Question: Whats the most annoying thing on Usenet?

                              Comment

                              Working...