OUTPUT: Num-parts: 2 -- Content-type: multipart/alternative Effective-type: multipart/alternative Body-file: NONE Num-parts: 2 -- Content-type: text/plain Effective-type: text/plain Body-file: this/is/my/path/2006-02-17/msg-32404-1.txt -- Content-type: text/html Effective-type: text/html Body-file: this/is/my/path/saved/2006-02-17/msg-32404-2.html -- Content-type: application/octet-stream Effective-type: application/octet-stream Body-file: this/is/my/path/saved/2006-02-17/-3.pdf Recommended-filename: 01267-TXN-CC-000086475[1].pdf #### # create a MIME::Parser object to # extract any attachments found within. my $parser = new MIME::Parser; $parser->output_dir( $savedir ); my $entity = $parser->parse_data($msg); # extract our mime parts and go through each one. my @parts = $entity->parts; foreach my $part (@parts) { # determine the path to the file in question. my $path = ($part->bodyhandle) ? $part->bodyhandle->path : undef; print "This is the $path \n"; #right here if it doesnt have the brackets it will give the correct file name if it does it will come back -1.pdf or some other count