The fragments of code below have been taken from one of my upcoming Perl articles which deals with something similar:
47 my $mp = new MIME::Parser; 48 $mp->ignore_errors(1); 49 $mp->extract_uuencode(1); 50 51 eval { $e = $mp->parse($fh); }; 52 my $error = ($@ || $mp->last_error); 53 54 if ($error) 55 { 56 $mp->filer->purge; # Get rid of the temp files 57 die "Error parsing the message: $error\n"; 58 } decode_entities($e); 103 sub decode_entities 104 { 105 my $ent = shift; 106 107 if (my @parts = $ent->parts) 108 { 109 decode_entities($_) for @parts; 110 } 111 elsif (my $body = $ent->bodyhandle) 112 { 113 my $type = $ent->head->mime_type; 114 115 setup_decoder($ent->head); 116 117 if ($type eq 'text/plain') 118 { print d($body->as_string); } 119 elsif ($type eq 'text/html') 120 { $parser->parse($body->as_string); } 121 else 122 { print "[Unhandled part of type $type]"; } 123 } 124 }
I'm sorry for not providing a direct link to the article, but I don't want to risk Google picking it up before publishing at TPJ :) You would need to rewrite the decode_entities() function to work with all the attachments. I haven't tested, but I would bet you can get to the attachment's payload using the ->as_string method.
Best regards
-lem, but some call me fokat
In reply to Re: Win2K MIME Decoding
by fokat
in thread Win2K MIME Decoding
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |