I have a html page (which is dynamically generated by a perl program),

Before worrying about how to convert the table on a page to an e-mailable format, have you considered modifying the generator to make your life easier?

If you store the results in a CSV file (check out File::Temp for one good method of making sure the name is unique, and Text::CSV_XS for making the CSV file) right before you send the HTML table out, then reference the file name in the HTML form (as a hidden element), you can have the mail-sending program attach said file to the message (check out MIME::Lite for that). Once you're there, you could even add the option to download said CSV file instead of having it mailed.

Since CSV files will typically open in a spreadsheet application on the users' computer (if the user is savvy enough to change that, they probably know how to deal with CSVs anyhow), it makes for a pretty nice interface.

What you don't want to do is e-mail the HTML verbatim; as others have pointed out, it will often be filtered away and/or irritate the recipient.

If you really can't modify the program that builds the page to start with, you could use LWP from your mailing program to retrieve the page, and something like HTML::TokeParser to get the data back into a Perl data structure. Then, either write out a text-only table (see format and write, or just use Text::Table), or generate and attach a CSV as above.

Just be sure of your real requirements before pursuing things too far.

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

In reply to Re: Is there any way to send HTML table information by radiantmatrix
in thread Is there any way to send HTML table information by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.