ecuguru has asked for the wisdom of the Perl Monks concerning the following question:
use Net::IMAP::Simple; use Email::Simple; use Email::MIME::Attachment::Stripper; my $username = "user"; my $password= "pass"; my $server = Net::IMAP::Simple->new( 'server' ); $server->login( $username,$password) || warn "Bad login!\n"; my $nmessages = $server->select( 'inbox' ); $number_of_messages = $nmessages; foreach my $msg ( 1 .. $number_of_messages ) { if ($server->seen( $msg )){ # print "This message has been read before...\n"; } else { print "New!"; my $email = Email::Simple->new( join '', @{$server->get( $ +msg )} ); my $stripper = Email::MIME::Attachment::Stripper->new($msg +); my Email::MIME $msg = $stripper->message; #my attachments = ..; This returns a list of all the attachments we f +ound in the message, as a hash of { filename, content_type, payload } +. my @attachments = $stripper->attachments; # print $email->header('Subject'), "\n"; # $data = $email->body, "\n"; # print $data; # print "\n"; } } wend; $server->quit(); exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Save Email Attachment to File
by brian_d_foy (Abbot) on Jan 23, 2006 at 19:51 UTC | |
|