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."
\n";
} else {
print "Attachment extracted !
\n";
}
# Delete the files containing the message content (we want only the attachment)
chdir (".");
unlink $entity->{'ME_Parts'}[0]->{'ME_Bodyhandle'}->{'MB_Path'} || warn ("Can't delete the message body file !");
}