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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.