Above is updated code, it stores almost all attachment according to condition.#!/usr/bin/perl use Mail::POP3Client; use MIME::Parser; #usage() unless scalar @ARGV == 3; my $pop = new Mail::POP3Client( HOST => 'server', USER => 'my', PASSWORD => 'pass' ); my $tmp_directory = "/tmp/attach"; my $parser = new MIME::Parser; $parser->output_dir($tmp_directory); $parser->output_prefix("attachment"); $parser->output_to_core(); open (FH,">>/tmp/msgtxt"); for (my $i = 1; $i <= $pop->Count(); $i++){ my $head = $pop->Head($i); if ($head =~ /X-MS-Has-Attach: yes/i){ foreach ( $pop->Head( $i ) ) { if( /^(From|Subject):\s+/i ) { if ( /Vincent/) { my $msg = $pop->HeadAndBody($i); if ($msg =~/^To: /) { print FH " $msg \n"; } my $entity = $parser->parse_data($msg) +; } } } # print "\n"; } } close(FH); $pop->Close(); sub usage { print "Usage: $0 <mail_server> <username> <password>\n"; exit; }
In reply to Re^4: How to parse outlook type attachment from inbox
by perlCrazy
in thread How to parse outlook type attachment from inbox
by perlCrazy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |