anonymonk has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to move folders to an "old_messages" folder after i have read and stripped the attachments from them but when i do it all of the messages it sends to the "old_messages" folder are blank and from "unknown sender" and the inbox is unchanged I checked around and nobody seems to have had this problem before (p.s. I graduated college a month ago during which i didn't even touch Perl and now i have been working with it for a whole 3 weeks so i apologize if this seems like an obvious fix).
use strict; use warnings; # required modules use Net::IMAP::Simple; use Email::MIME; use IO::Socket::SSL; use Email::MIME::Attachment::Stripper;
###IMAP connecting here### my $nm = $imap->select('INBOX'); for ( my $i = 1 ; $i <= $nm ; $i++ ) { if (!$imap->seen($i) ) { next; } else { my $es = Email::MIME->new( join '', @{ $imap->get($i) } ); my $text = $es->body; my $stripper = Email::MIME::Attachment::Stripper->new($es); my @attachments = $stripper->attachments; my $l = 0; foreach $_(@attachments) { my $url = ""; my $fh = IO::File->new(); open($fh, '>', "$filepath"."$_->{filename}"); binmode($fh); print $fh "$_->{payload}\n"; $fh->close; } $imap->put( 'OLD_MESSAGES', $es, "") or warn $imap->errstr; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Moving gmail messages with net::imap::simple
by 1nickt (Canon) on Jun 27, 2015 at 00:57 UTC |