Sample code for 30+ languages & platforms
Unicode C++

Access Attached Message (Embedded Email)

How to access an email embedded within another email (i.e. an attached message).

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkEmailW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkEmailW email;

    // Load an email from a .eml
    success = email.LoadEml(L"embeddedEmail.eml");
    if (success == false) {
        wprintf(L"%s\n",email.lastErrorText());
        return;
    }

    // Display how many attached emails are embedded within
    // this one:
    int numAttached = email.get_NumAttachedMessages();
    wprintf(L"numAttached = %d\n",numAttached);

    // Get the 1st attached message.
    CkEmailW email2;
    success = email.GetAttachedEmail(0,email2);
    if (success == true) {

        // Display the subject, From, and a header field...
        wprintf(L"%s\n",email2.subject());
        wprintf(L"%s\n",email2.ck_from());
        wprintf(L"%s\n",email2.getHeaderField(L"X-SOMETHING"));
    }
    }