adding linebreak in mailto body

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

    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:myemail @mycompany.com? subject=test
    email&body=' + ebody;

    If I do an "alert(ebod y);" 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?
  • HikksNotAtHome

    #2
    Re: adding linebreak in mailto body

    In article <f770f2e4.03081 91215.79adea5c@ posting.google. com>,
    steve_irakliano s@hotmail.com (nAmYzArC) writes:
    [color=blue]
    >Hi everyone,
    >
    >I'm setting the body of an email using values from a form
    >[/color]





    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.

    Comment

    • nAmYzArC

      #3
      Re: adding linebreak in mailto body

      > 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.

      Comment

      • Mr. Clean

        #4
        Re: adding linebreak in mailto body

        In article <f770f2e4.03082 00820.3dad966e@ posting.google. com>,
        steve_irakliano s@hotmail.com says...[color=blue][color=green]
        > > If you want to reliably send email, send it from the server.[/color]
        >
        > 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.
        >[/color]
        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.

        Comment

        • HikksNotAtHome

          #5
          Re: adding linebreak in mailto body

          In article <f770f2e4.03082 00820.3dad966e@ posting.google. com>,
          steve_irakliano s@hotmail.com (nAmYzArC) writes:
          [color=blue][color=green]
          >> If you want to reliably send email, send it from the server.[/color]
          >
          >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.[/color]

          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.

          Comment

          • Mr. Clean

            #6
            Re: adding linebreak in mailto body

            In article <f770f2e4.03081 91215.79adea5c@ posting.google. com>,
            steve_irakliano s@hotmail.com says...[color=blue]
            > 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:myemail @mycompany.com? subject=test
            > email&body=' + ebody;
            >
            > If I do an "alert(ebod y);" 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?
            >[/color]
            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.


            Comment

            • rh

              #7
              Re: adding linebreak in mailto body

              "Vjekoslav Begovic" <vjbegovic@inet .hr> wrote in message news:<bhv5jf$sa l$1@sunce.iskon .hr>...
              <snip>[color=blue]
              >
              > 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/[/color]

              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

              Comment

              • Laurent Bugnion, GalaSoft

                #8
                Re: adding linebreak in mailto body

                Hi,

                Vjekoslav Begovic wrote:[color=blue]
                > "nAmYzArC" <steve_iraklian os@hotmail.com> wrote in message
                > news:f770f2e4.0 308191215.79ade a5c@posting.goo gle.com...
                >[color=green]
                >>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.locati on.href = 'mailto:myemail @mycompany.com? subject=test
                >>email&body= ' + ebody;
                >>
                >>If I do an "alert(ebod y);" 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?[/color]
                >
                >
                > 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/[/color]

                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

                Comment

                • Vjekoslav Begovic

                  #9
                  Re: adding linebreak in mailto body

                  "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in
                  message news:bi1k0v$8hc $1@rex.ip-plus.net...
                  [color=blue]
                  > 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.[/color]

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

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



                  Comment

                  • nAmYzArC

                    #10
                    Re: adding linebreak in mailto body

                    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" <vjbegovic@inet .hr> wrote in message news:<bi1p37$mt f$1@sunce.iskon .hr>...[color=blue]
                    > "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in
                    > message news:bi1k0v$8hc $1@rex.ip-plus.net...
                    >[color=green]
                    > > 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.[/color]
                    >
                    > 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.
                    >[color=green]
                    > > 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.[/color]
                    >
                    > OK, but OP asked <cite>is there something that can give be a line
                    > break?</cite>.[/color]

                    Comment

                    • nAmYzArC

                      #11
                      Re: adding linebreak in mailto body

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

                      Mr. Clean <mrclean@protct orandgamble.com > wrote in message news:<MPG.19ad7 18b45603fa8989a 5f@news-server.austin.r r.com>...[color=blue]
                      > In article <f770f2e4.03081 91215.79adea5c@ posting.google. com>,
                      > steve_irakliano s@hotmail.com says...[color=green]
                      > > 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:myemail @mycompany.com? subject=test
                      > > email&body=' + ebody;
                      > >
                      > > If I do an "alert(ebod y);" 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?
                      > >[/color]
                      > 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.[/color]

                      Comment

                      • Laurent Bugnion, GalaSoft

                        #12
                        Re: adding linebreak in mailto body

                        Hi.

                        nAmYzArC wrote:
                        [color=blue]
                        > Whoa people -
                        > There seems to be alot of un-needed debate here.[/color]

                        <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

                        Comment

                        • nAmYzArC

                          #13
                          Re: adding linebreak in mailto body

                          Mr. Clean <mrclean@protct orandgamble.com > wrote in message news:<MPG.19ad7 18b45603fa8989a 5f@news-server.austin.r r.com>...[color=blue]
                          > In article <f770f2e4.03081 91215.79adea5c@ posting.google. com>,
                          > steve_irakliano s@hotmail.com says...[color=green]
                          > > 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:myemail @mycompany.com? subject=test
                          > > email&body=' + ebody;
                          > >
                          > > If I do an "alert(ebod y);" 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?
                          > >[/color]
                          > 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.[/color]

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

                          Comment

                          • Mr. Clean

                            #14
                            Re: adding linebreak in mailto body

                            <SNIP>

                            [color=blue][color=green]
                            > > 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.[/color]
                            >
                            > Actually using this gave me an 'object expected' error.
                            >[/color]


                            Without seeing your complete code, I can't tell what would be causing that
                            because fromCharCode(10 ) should work just fine.

                            Comment

                            • Lasse Reichstein Nielsen

                              #15
                              Re: adding linebreak in mailto body

                              Mr. Clean <mrclean@protct orandgamble.com > writes:
                              [color=blue]
                              > Without seeing your complete code, I can't tell what would be causing that
                              > because fromCharCode(10 ) should work just fine.[/color]

                              Shouldn't that be "String.fromCha rCode(10)"?
                              /L
                              --
                              Lasse Reichstein Nielsen - lrn@hotpop.com
                              Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
                              'Faith without judgement merely degrades the spirit divine.'

                              Comment

                              Working...