(C++) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message).
#include <CkEmail.h>
void ChilkatSample(void)
{
CkEmail email;
// Load an email from a .eml
bool success = email.LoadEml("embeddedEmail.eml");
if (success != true) {
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 = 0;
email2 = email.GetAttachedMessage(0);
if (email.get_LastMethodSuccess() == 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";
}
}
|