Sample code for 30+ languages & platforms
Node.js Requires Chilkat v11.0.0+

List message headers in their original field order

See more Email Object Examples

Walk the top-level header fields by index. Read the name and value at the same index so repeated fields such as Received retain their separate values. Attachment headers belong to the attachment’s MIME part.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    var email = new chilkat.Email();
    success = email.LoadEml("message.eml");
    if (success !== true) {
        console.log(email.LastErrorText);
        return;
    }

    var i = 0;
    while ((i < email.NumHeaderFields)) {
        //  Read the value by index because names can repeat.
        console.log(email.GetHeaderFieldName(i) + ": " + email.GetHeaderFieldValue(i));
        i = i+1;
    }


}

chilkatExample();