Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Parsing Subject and Body Of E-Mail Message

by zwon (Monsignor)
on Dec 11, 2009 at 22:59 UTC ( #812458=note: print w/ replies, xml ) Need Help??


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

Documentation for Net::IMAP::Simple provides example of reading subjects using Email::Simple. You can expand it to read also body.


Comment on Re: Parsing Subject and Body Of E-Mail Message
Re^2: Parsing Subject and Body Of E-Mail Message
by ProgramIT (Novice) on Dec 15, 2009 at 17:47 UTC
    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('SERVER.HOSTNAME.com') || 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;

      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) } );

      to

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://812458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-07-12 02:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls