Hi,

I've managed to write a little function which will parse emails grabbed via Mail::POP3Client, and it works fine (it extracts the files to a folder, within a sub-folder - i.e msg-1291891283-19924-4.

The problems I have, is:

1) I need to get a list of these files, so I can rename them with a "prefix" them with yyyymmddHHMMSS_ 2) I need to rename stuff like “B%DClen%FCt %7E .Cey.pdf” into its "real" filename, i.e “BÜlenüt ~ .Ceylan. – Test.pdf”

The code is as follows:
sub process_mail { my $mesage_body = $_[0]; # Create a new MIME::Parser object my $parser = new MIME::Parser; # Tolerant mode $parser->ignore_errors(1); # Output to a file $parser->output_to_core(0); # Output to a per message folder $parser->output_under("/kunden/217787_60385/onexma/archiv/Clients/ +000000"); # Parsing the message my $entity = $parser->parse_data($_[0]); my $error = ($@ || $parser->last_error); if ($error) { print $error."<br>\n"; } else { print "Attachment extracted !<br>\n"; } # Delete the files containing the message content (we want only th +e attachment) chdir ("."); unlink $entity->{'ME_Parts'}[0]->{'ME_Bodyhandle'}->{'MB_Path'} || + warn ("Can't delete the message body file !"); }


I've had a look through the `man` for MIME::Parser, and can't see anything that would do this.

Any of you guys got any ideas/pointers? :)

TIA!

Andy

In reply to MIME::Parser- get the filename + folder it was extracted to? by ultranerds

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.