Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
use Mail::POP3Client; use MIME::Parser; usage() unless scalar @ARGV == 3; my $pop = new Mail::POP3Client( HOST => $ARGV[0], USER => $ARGV[1], PASSWORD => $ARGV[2] ); my $tmp_directory = "/tmp"; my $parser = new MIME::Parser; $parser->output_dir($tmp_directory); $parser->output_prefix("attachment"); $parser->output_to_core(); my $entity = $parser->read(\*STDIN); for (my $i = 1; $i <= $pop->Count(); $i++){ foreach my $line ($pop->Head($i)){ if($line =~ /^(From):\s+/i){ print $line, "\n"; }elsif($line =~ /X-MS-Has-Attach: yes/i){ print "this email has a attachment\n\n"; } } } sub usage { print "Usage: $0 <mail_server> <username> <password>\n"; exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parse email attachment
by Mr. Muskrat (Canon) on Jan 09, 2003 at 23:40 UTC | |
|
Re: parse email attachment
by arrow (Friar) on Jan 10, 2003 at 03:41 UTC | |
|
Re: parse email attachment
by oakbox (Chaplain) on Jan 10, 2003 at 07:54 UTC |