(C++) 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.
#include <CkEmail.h>
void ChilkatSample(void)
{
bool success = false;
CkEmail email;
// Load an email from a .eml
success = email.LoadEml("embeddedEmail.eml");
if (success == false) {
std::cout << email.lastErrorText() << "\r\n";
return;
}
// Display how many attached emails are embedded within
// this one:
int numAttached = email.get_NumAttachedMessages();
std::cout << "numAttached = " << numAttached << "\r\n";
// Get the 1st attached message.
CkEmail email2;
success = email.GetAttachedEmail(0,email2);
if (success == true) {
// Display the subject, From, and a header field...
std::cout << email2.subject() << "\r\n";
std::cout << email2.ck_from() << "\r\n";
std::cout << email2.getHeaderField("X-SOMETHING") << "\r\n";
}
}
|