perl - Email::MIME can't parse message from Gmail -


so i'm using perl , email::mime email gmail. here code:

use net::imap::simple::gmail; use email::mime;   # creat object read emails $server = 'imap.gmail.com'; $imap = net::imap::simple::gmail->new($server);   # user , password $user = 'username@gmail.com'; $password = 'passowrd';  $imap->login($user => $password);  # select inbox , returns number of messages $numberofmessages = $imap->select('inbox');  # let's go through messages top  ($i = 1; $i <= $numberofmessages; $i++) {         $top = $imap->top($i);     print "top = $top\n";      $email = email::mime->new( join '', @{ $imap->top($i) } );     $body = $email->body_str;     print "body = $body\n"; }#end 

when run it, following error:

can't body string multipart/related; boundary="----=_part_6796768_17893472.1369009276778"; type="text/html" @ /library/perl/5.8.8/email/mime.pm line 341 email::mime::body_str('email::mime=hash(0x87afb4)') called @ readphoneemailfeed.pl line 37 

if replace

$body = $email->body_str; 

with

$body = $email->body; 

i output:

body =  

(i.e. empty string)

what's going on here? there way me raw body of message (->body_raw doesn't work either)? i'm okay parsing out body using regex

email::mime not best documented package have ever seen.

the body , body_str methods work on single mime part. simple text message. more complex use parts method each mime component email::mime object. body , body_str methods should work on that. html formatted message have 2 mime parts: text/plain , text/html.

this isn't want should enough show going on.

my @parts = $email->parts; $part (@parts) { print "type: ", $part->content_type, "\n"; print "body: ", $part->body, "\n"; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -