D
dupont2br
I am trying to use mail::webmail::gmail to automatically download all
attachments sent to a gmail account. i get daily reports and i want to
save the ZIP files attached to a local directory. I cannot figure out
how to save the attachment to a local directory once I have identified
messages with an attachment. Here is my code so far:
Thanks for your suggestions,
Eric
_______________________________________________________________________________
#!/usr/bin/perl
use Mail::Webmail::Gmail;
use Archive::Extract;
my $user = $ARGV[0];
my $pass = $ARGV[1];
my $folder = 'INBOX';
my $gmail = Mail::Webmail::Gmail->new(
username => $user, password => $pass,
);
my $messages = $gmail->get_messages(
label => $Mail::Webmail::Gmail::FOLDERS{ $folder }
);
foreach ( @{$messages}) {
my $email = $gmail->get_indv_email( msg => $_ );
if ( defined( $email->{ $_->{ 'id' } }->{ 'attachments' } ) )
{
foreach ( @{ $email->{ $_->{ 'id' } }-
### not sure if this is proper way of getting attachment
my $attach = $gmail->get_attachment( attachment => $_ );
### not sure what to do here to save to local directory
}
}
attachments sent to a gmail account. i get daily reports and i want to
save the ZIP files attached to a local directory. I cannot figure out
how to save the attachment to a local directory once I have identified
messages with an attachment. Here is my code so far:
Thanks for your suggestions,
Eric
_______________________________________________________________________________
#!/usr/bin/perl
use Mail::Webmail::Gmail;
use Archive::Extract;
my $user = $ARGV[0];
my $pass = $ARGV[1];
my $folder = 'INBOX';
my $gmail = Mail::Webmail::Gmail->new(
username => $user, password => $pass,
);
my $messages = $gmail->get_messages(
label => $Mail::Webmail::Gmail::FOLDERS{ $folder }
);
foreach ( @{$messages}) {
my $email = $gmail->get_indv_email( msg => $_ );
if ( defined( $email->{ $_->{ 'id' } }->{ 'attachments' } ) )
{
foreach ( @{ $email->{ $_->{ 'id' } }-
{ 'attachments' } } ) {
### not sure if this is proper way of getting attachment
my $attach = $gmail->get_attachment( attachment => $_ );
### not sure what to do here to save to local directory
}
}