Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: Parsing Subject and Body Of E-Mail Message

by ProgramIT (Novice)
on Dec 15, 2009 at 17:47 UTC ( #812910=note: print w/replies, xml ) Need Help??

in reply to Re: Parsing Subject and Body Of E-Mail Message
in thread Parsing Subject and Body Of E-Mail Message

Can you explain how to read the body. I have managed to read the headers, but can't find out how to read the body. Here's What I currently have
#!/usr/bin/perl use strict; use warnings; use Net::IMAP::Simple::SSL; use Email::Simple; # Create the object my $imap = Net::IMAP::Simple::SSL->new('') || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; # Log on if(!$imap->login('USER','PASSWORD')){ print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } # Print the subject's of all the messages in the INBOX my $nm = $imap->select('INBOX'); for(my $i = 1; $i <= $nm; $i++){ if($imap->seen($i)){ print "*"; } else { print " "; } my $es = Email::Simple->new(join '', @{ $imap->top($i) } ); #print $es->as_string; printf("[%03d] %s\n", $i, $es->header('Subject') . " " . $es-> +header('from')); print $es->body; } $imap->quit;

Replies are listed 'Best First'.
Re^3: Parsing Subject and Body Of E-Mail Message
by amccartney (Initiate) on Jul 11, 2013 at 02:46 UTC

    I know this is an old post, however I came across it when trying to figure this out myself.

    For others stuck with this example, you will need to change the following line from:

     my $es = Email::Simple->new(join '', @{ $imap->top($i) } );


    my $es = Email::Simple->new( join '', @{ $imap->get($i) } );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://812910]
[ww]: (but pls don't s/senior/senile/ ... not yet
[karlgoethebier]: A bit more audience now: The Impact of Information Sources on Code Security Very interesting IMHO...
[karlgoethebier]:'s about copy & paste ;-)
[ww]: Wonder what IEEE would have thought w/survey based on PM/perl
[ww]: s/thought/found/
[erix]: that title is a broken* sentence, no? But maybe that's deliberate
[karlgoethebier]: ww:My first thought, to be honest...
[erix]: and those authors' names don't look like native english speakers. Then again, neither am I :)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-09-25 14:45 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (280 votes). Check out past polls.