(Perl) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message). Note: This example requires Chilkat v11.0.0 or greater.
use chilkat();
$success = 0;
$email = chilkat::CkEmail->new();
# Load an email from a .eml
$success = $email->LoadEml("embeddedEmail.eml");
if ($success == 0) {
print $email->lastErrorText() . "\r\n";
exit;
}
# Display how many attached emails are embedded within
# this one:
$numAttached = $email->get_NumAttachedMessages();
print "numAttached = " . $numAttached . "\r\n";
# Get the 1st attached message.
$email2 = chilkat::CkEmail->new();
$success = $email->GetAttachedEmail(0,$email2);
if ($success == 1) {
# Display the subject, From, and a header field...
print $email2->subject() . "\r\n";
print $email2->ck_from() . "\r\n";
print $email2->getHeaderField("X-SOMETHING") . "\r\n";
}
|