Sample code for 30+ languages & platforms
Node.js

Access Attached Message (Embedded Email)

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

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var email = new chilkat.Email();

    // Load an email from a .eml
    success = email.LoadEml("embeddedEmail.eml");
    if (success == false) {
        console.log(email.LastErrorText);
        return;
    }

    // Display how many attached emails are embedded within
    // this one:
    var numAttached = email.NumAttachedMessages;
    console.log("numAttached = " + numAttached);

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

        // Display the subject, From, and a header field...
        console.log(email2.Subject);
        console.log(email2.From);
        console.log(email2.GetHeaderField("X-SOMETHING"));
    }


}

chilkatExample();