heh! I'm doing almost exactly the same thing. I tested this and it works for me:
in reply to Re: Dealing with "Detachments"
in thread Dealing with "Detachments"
For actual use I'd create the directory internally from the program and then remove it when finished. You'll also want to come up with some dynamic means of choosing the directory name since you don't want to try and delete the directory while another instance of the program is trying to write to it.
## my alias line:
## menu: \menu, "|/usr/perl/mime.parser.p"
## '\menu' keeps a copy in the inbox for account menu
my $parser = new MIME::Parser;
## The secret here is that the directory must pre-exist
## and must be writable by the daemon that runs the
## parsing script. In my case user=daemon group=other
## I determined the correct values by initially making
## /tmp/mimemail using permissions 777.
my $entity = $parser->read(\*STDIN)
or die "\n\nCouldn't parse MIME stream\n\n";
All you have to do now is figure out how to scarf the other portions of the original message using MIME::Parser before resending with MIME::Lite.