SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mailto body length

    I am trying to create a link which opens an email and puts a table in the body BUT DOES NOT SEND IT - LET ME SAY AGAIN - DOES NOT SEND IT!!!

    The trouble seems to be that the "body=" will only accept a certain amount of code before it fails. How can I solve this problem?

    e.g.
    <a href="mailto:me@here.com?body=<table>2 rows</table>">click here</a>

    works fine (although it displays the html rather than rendering - any idea about that as well?!)

    <a href="mailto:me@here.com?body=<table>9 rows</table>">click here</a>

    does nothing

    Any suggestions?

    Cheers

    monkey
    monkey - the rest is history

  2. #2
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Firstly as far as I am aware, you cannot include HTML elements as part of an address (which is what the mailto protocol forms) due to how it would be interpreted (though you could probably use CDATA characters (&amp; for example) to work around this problem. However as to the issue with the length of mailto, there is a fixed and standardised maximum length an address can be (whatever protocol it origionates from) and you are simply pushing the technology past its intended usage. Simply put, you cannot use mailto in that capacity and quite frankly you should not be using mailto in the first place, you should be using a customised HTML form to send emails with predefined content (or large amounts of data to fill in).

  3. #3
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AlexDawson View Post
    Firstly as far as I am aware, you cannot include HTML elements as part of an address (which is what the mailto protocol forms) due to how it would be interpreted (though you could probably use CDATA characters (&amp; for example) to work around this problem. However as to the issue with the length of mailto, there is a fixed and standardised maximum length an address can be (whatever protocol it origionates from) and you are simply pushing the technology past its intended usage. Simply put, you cannot use mailto in that capacity and quite frankly you should not be using mailto in the first place, you should be using a customised HTML form to send emails with predefined content (or large amounts of data to fill in).
    Unfortunately, I thought this was the case, but I thought I'd try it anyway

    cheers
    monkey - the rest is history

  4. #4
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This would be a handy link, but there are two important challenges.

    First, you need to encode any reserved characters used in the URL. For example a line break must be encoded as "%0D%0A".

    Second, you don't know which mail client will be used, so the rendering of HTML is unpredictable.

    If implementing the functionality myself, I'd use a link that brings up an editor and/or sends the email from phpmail or a server side technology. You may have additional requirements.

    -Michael

  5. #5
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason behind doing this was lazyness! The table needs to be either printed or emailed - using maito would allow them to create the email and print it off if required. I'll have to stop being lazy and do it the proper way I suppose

    Cheers all
    monkey - the rest is history

  6. #6
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First thing you're running into is probably the max allowable length of the query string.

    Probably the best way to handle it is on the server end. Have an "email report" link on the page, and when that link is clicked the query that produced it is posted to the server, which takes the results, formats it into an email, and sends it.

    You'll need some security in place to keep other folks from hijacking it, but that's what I'd start looking at.

  7. #7
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Arlen View Post
    First thing you're running into is probably the max allowable length of the query string.

    Probably the best way to handle it is on the server end. Have an "email report" link on the page, and when that link is clicked the query that produced it is posted to the server, which takes the results, formats it into an email, and sends it.

    You'll need some security in place to keep other folks from hijacking it, but that's what I'd start looking at.
    Thanks for the help - however please read the RED WRITING in my original post!

    I've sorted this now by having a print option OR an email option.

    cheers
    monkey - the rest is history


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •