PHP ActiveX Requires Chilkat v11.0.0+
PHP ActiveX
Read an attached email
See more Email Object Examples
Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.
Chilkat PHP ActiveX Downloads
<?php
$success = 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
$wrapper = new COM("Chilkat.Email");
$success = $wrapper->LoadEml('forward-as-attachment.eml');
if ($success != 1) {
print $wrapper->LastErrorText . "\n";
exit;
}
print 'Cover note: ' . $wrapper->Subject . "\n";
if ($wrapper->NumAttachedMessages == 0) {
print 'No attached messages.' . "\n";
exit;
}
$nested = new COM("Chilkat.Email");
$i = 0;
while (($i < $wrapper->NumAttachedMessages)) {
$success = $wrapper->GetAttachedEmail($i,$nested);
if ($success != 1) {
print $wrapper->LastErrorText . "\n";
exit;
}
print 'Original author: ' . $nested->From . "\n";
print 'Original subject: ' . $nested->Subject . "\n";
print 'Files on the original: ' . $nested->NumAttachments . "\n";
$i = $i + 1;
}
?>