(PHP ActiveX) Unpack HTML Email to Files
Unpacks an HTML email into an HTML file and related files (images and style sheets). The links within the HTML are updated to point to the files unpacked and saved to disk.
<?php
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Email')
$email = new COM("Chilkat.Email");
$success = $email->LoadEml('qa_data/eml/happyHour.eml');
if ($success != 1) {
print $email->LastErrorText . "\n";
exit;
}
// Is this an HTML email?
if ($email->HasHtmlBody() == 1) {
// Unpack the HTML to files. The image and css URLs
// in the HTML are modified to point to the files extracted to disk.
$unpackDir = 'qa_output/emails';
$partsSubdir = 'images';
$htmlFilename = 'happyHour.html';
$success = $email->UnpackHtml($unpackDir,$htmlFilename,$partsSubdir);
if ($success != 1) {
print $email->LastErrorText . "\n";
exit;
}
print 'Success.' . "\n";
}
?>
|