Perl Requires Chilkat v11.0.0+
Perl
Extract Files from MIME
See more MIME Examples
Extract files from a MIME message.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
my $mime = Chilkat2::Mime->new;
# Load a MIME document from a file:
# (.mht and .eml files contain MIME).
my $success = $mime->LoadMimeFile('mst.mht');
if (!$success) {
print $mime->LastErrorText, "\n";
exit;
}
my $st = Chilkat2::StringTable->new;
$success = $mime->PartsToFiles('/temp/mimeParts', $st);
if (!$success) {
print $mime->LastErrorText, "\n";
exit;
}
my $n = $st->Count;
# Display the paths of the files created:
my $i = 0;
while ($i < $n) {
print $st->StringAt($i), "\n";
$i = $i + 1;
}