Brother monks ... in all humbleness, I beg for assistance ...

I am trying to retrieve the individual components of an e-mail message and then re-write it (to a database or to another e-mail box). I am using Mail:Internet which retrieves the "To", "From" and "Subject" by using the get() command. I tried this for the body ... didn't work. Turns out I have to use body(); . Fine, easy enough. I assigned the values which body() calls to a scalar ($body, for instance). Then I tried to
print MAIL '$body\n';
, but it didn't work. It turns out that $body is some kind of an array b/c when I
print MAIL "$body[0]\n";
, I get the first line of the body. I tried to save the output of body() to @body, but the program wouldn't run.

The problem is that I now I want to retrieve and print out a bunch of different e-mail bodies, all of different lengths. So I was going to run a for loop using $#body as the last value to run the loop. But it turns out I can't use this value because (I'm suppossing) its a scalar ($body).

Argghhhh! If I could just get the body contents as a scalar I could just print them out with print "$body\n"; or even if I had it as an array I could run a for loop through the last value of the array and just print it out, but I can't define the last value with $#body because it's not a "@"!! I could just run the for loop through a set value of 1000 lines, but how pretty is that? Not very.

If there is another way to retrieve the body of an e-mail as a usable variable (scalar or array) please let me know.


I beg forgiveness for any misused terminology ... I am still yet a neophyte to these waters.

cdherold

2001-04-06 Edit by Corion : Added CODE tags


In reply to Retrieval of e-mail body by cdherold

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.