PHP ActiveX Requires Chilkat v11.0.0+
PHP ActiveX
Read the plain-text and HTML bodies separately
See more Email Object Examples
When both alternatives exist, Body returns HTML. Use the explicit body accessors to choose text for an index or HTML for a viewer. This example reads alternatives.eml from the previous example.
Chilkat PHP ActiveX Downloads
<?php
$success = 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
$email = new COM("Chilkat.Email");
$success = $email->LoadEml('alternatives.eml');
if ($success != 1) {
print $email->LastErrorText . "\n";
exit;
}
// A message can have either representation, both, or neither.
if ($email->HasPlainTextBody() == 1) {
print 'Plain text: ' . $email->getPlainTextBody() . "\n";
}
if ($email->HasHtmlBody() == 1) {
print 'HTML source: ' . $email->getHtmlBody() . "\n";
}
if (($email->HasPlainTextBody() == 0) and ($email->HasHtmlBody() == 0)) {
print 'No text or HTML body. Inspect the MIME parts.' . "\n";
}
?>