Using mailto: to mail a link containing a querystring

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

    Using mailto: to mail a link containing a querystring

    I have a ASP page that after saveing data to the database it will
    write the following script code to the page:
    <script>
    document.locati on='mailto:or@m ailadr.se?body= http://myWebserver/page.asp?docID= 17&login=HAL&su bject=report';
    </script>

    This all looks well but when I se the actual mail the &login=LAS part
    of the link in the body is not there! The subject is correct! It all
    looks ok apart from the missing part of the links querystring.

    I tried to use Server.UrlEncod e but that just left the body of the
    mail compleatly empty.

    /best regards Olaf
  • Evertjan.

    #2
    Re: Using mailto: to mail a link containing a querystring

    Olaf wrote on 09 aug 2004 in comp.lang.javas cript:
    [color=blue]
    > I have a ASP page that after saveing data to the database it will
    > write the following script code to the page:
    > <script>
    > document.locati on='mailto:or@m ailadr.se?body= http://myWebserver/page.as
    > p?docID=17&logi n=HAL&subject=r eport'; </script>
    >
    > This all looks well but when I se the actual mail the &login=LAS part
    > of the link in the body is not there! The subject is correct! It all
    > looks ok apart from the missing part of the links querystring.
    >
    > I tried to use Server.UrlEncod e but that just left the body of the
    > mail compleatly empty.
    >[/color]

    How would the last two "&"s know which "?" they have to follow?

    In other words:

    the mail body could contain:

    and the mail login:
    HAL
    and the mail subject:
    report

    but there is no mail login, so where has HAL to go?.

    Again in other words: you cannot do that.

    Moreover the "mailto'-protocol is not clearly defined over different mail
    clients.

    =============== ============

    If you really want to get somewhere try this:

    document.locati on=
    'mailto:or@mail adr.se?body=htt p://myWebserver.se/docID17.HAL.rep ort.xyz'

    and when the recipient wants to connect your customized 404.asp page will
    detect .xyz and redirect this nonexisting URL to where it should be
    (page.asp) and have docID17, HAL and report in session variables.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Ivo

      #3
      Re: Using mailto: to mail a link containing a querystring

      "Olaf" wrote[color=blue]
      > I have a ASP page that after saveing data to the database it will
      > write the following script code to the page:
      > <script>
      >[/color]
      document.locati on='mailto:or@m ailadr.se?body= http://myWebserver/page.asp?doc
      ID=17&login=HAL &subject=report ';[color=blue]
      > </script>
      >
      > This all looks well but when I se the actual mail the &login=LAS part
      > of the link in the body is not there! The subject is correct! It all
      > looks ok apart from the missing part of the links querystring.
      >
      > I tried to use Server.UrlEncod e but that just left the body of the
      > mail compleatly empty.
      >[/color]

      Use the built-in escape function to encode the url:
      document.locati on='mailto:or@m ailadr.se?body= '+escape('http://myWebserver/pa
      ge.asp?docID=17 &login=HAL')+'& subject=report' ;

      --Iv


      Comment

      • Hywel

        #4
        Re: Using mailto: to mail a link containing a querystring

        In article <697f2a2c.04080 90651.3c788ba2@ posting.google. com>, Olaf
        says...[color=blue]
        > I have a ASP page that after saveing data to the database it will
        > write the following script code to the page:
        > <script>
        > document.locati on='mailto:or@m ailadr.se?body= http://myWebserver/page.asp?docID= 17&login=HAL&su bject=report';
        > </script>[/color]

        Cool - a malformed URL. Chaos will ensue.

        --
        Hywel


        Comment

        • Michael Winter

          #5
          Re: Using mailto: to mail a link containing a querystring

          On 9 Aug 2004 07:51:21 -0700, Olaf <olaf_ripegard@ hotmail.com> wrote:
          [color=blue]
          > I have a ASP page that after saveing data to the database it will
          > write the following script code to the page:
          > <script>
          > document.locati on='mailto:or@m ailadr.se?body= http://myWebserver/page.asp?docID= 17&login=HAL&su bject=report';
          > </script>
          >
          > This all looks well but when I se the actual mail the &login=LASpa rt of
          > the link in the body is not there! The subject is correct!It all looks
          > ok apart from the missing part of the linksquerystrin g.
          >
          > I tried to use Server.UrlEncod e but that just left the body of themail
          > compleatly empty.[/color]

          The mailto scheme is flawed and should be avoided. It would be much more
          reliable to use a server-side mail script. There are plenty of them around
          and you'll have no problems setting the subject, or any other field for
          that matter.

          I'll stop there though. This subject has been done to death.

          Mike

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail

          Comment

          • Olaf

            #6
            Re: Using mailto: to mail a link containing a querystring

            "Ivo" <no@thank.you > wrote in message news:<41179c4d$ 0$31070$ee9da40 f@news.wanadoo. nl>...
            [color=blue]
            > Use the built-in escape function to encode the url:
            > document.locati on='mailto:or@m ailadr.se?body= '+escape('http://myWebserver/pa
            > ge.asp?docID=17 &login=HAL')+'& subject=report' ;
            >
            > --Iv[/color]

            Thanks Ivo! That worked just the way I wanted it to.
            best regards Olaf

            Comment

            Working...