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

Pass an Email object to the MIME API

See more Email Object Examples

Serialize an Email into a fresh BinData buffer and load those bytes into Mime to inspect the tree. Keep the original file separately when byte-for-byte preservation matters, such as for DKIM verification.

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 mimeBytes = new chilkat.BinData();
    success = email.GetMimeBd(mimeBytes);
    if (success !== true) {
        console.log(email.LastErrorText);
        return;
    }

    var mime = new chilkat.Mime();
    success = mime.LoadMimeBd(mimeBytes);
    if (success !== true) {
        console.log(mime.LastErrorText);
        return;
    }

    console.log(mime.GetStructure("text"));

}

chilkatExample();