Sample code for 30+ languages & platforms
Node.js

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var mime = new chilkat.Mime();

    // Load a MIME document from a file:
    // (.mht and .eml files contain MIME).
    success = mime.LoadMimeFile("mst.mht");
    if (success == false) {
        console.log(mime.LastErrorText);
        return;
    }

    var st = new chilkat.StringTable();
    success = mime.PartsToFiles("/temp/mimeParts",st);
    if (success == false) {
        console.log(mime.LastErrorText);
        return;
    }

    var n = st.Count;

    // Display the paths of the files created:
    var i = 0;
    while (i < n) {
        console.log(st.StringAt(i));
        i = i+1;
    }


}

chilkatExample();