hi there, i'm writing on a script to reads emails(IMAP). I use also Net::IMAP::Simple. i have to read and compare "subject", "From" and "Body" to find needed strings. I stay in the beginning my problem is, i got no values for body. that's the way how i going on in my script:
foreach $msg_id (keys(%$Messages)) { my $MsgContent = $imap->get($msg_id); #my $Inhalt = $imap->get($msg_id); # print $Inhalt; PrintList(@$MsgContent); } sub PrintList { # Assign parameter to a local variable my (@lines) = @_; # Declare local variables my ($from, $line, $subject, $body); # Check each line in the header foreach $line (@lines) { if($line =~ m/^From: (.*)/) { # We found the "From" field, so let's # get what we need $from = $1; $from =~ s/"|<.*>//g; $from = substr($from, 0, 39); } elsif( $line =~ m/^Subject: (.*)/) { # We found the "Subject" field, so let's # get what we need $subject = $1; $subject = substr($subject, 0, 29); } elsif( $line =~ m/^Body: (.*)/ ) { $body = $1; $body = substr($body, 0, 29); #print $body; } # If we have parsed the "From" and "Subject" # field, then we don't need to keep on going. # Let's quit the loop here. last if( defined($subject) && defined($from) && defined($body) ); } # Print the result printf "From: %-40s Subject: %s\nInhalt: %s\n", $from, $subject, $bo +dy; }# end: PrintList()

is there something wrong!? Subject und from are showing from each email but not the body!

In reply to Using Net::IMAP::Simple to read emails by eizo

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.