(Perl) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message).
use chilkat();
$email = chilkat::CkEmail->new();
# Load an email from a .eml
$success = $email->LoadEml("embeddedEmail.eml");
if ($success != 1) {
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 is a Email
$email2 = $email->GetAttachedMessage(0);
if ($email->get_LastMethodSuccess() == 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";
}
|