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

Export HTML and related files into a directory

See more Email Object Examples

Choose a separate directory for each message. UnpackHtml writes the HTML file, exports its related resources, and rewrites links to their local paths. This is useful when images should remain separate files.

Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var email = new CkEmail();
success = email.LoadEml("inline-image.eml");
if (success !== true) {
    console.log(email.LastErrorText);
    return;
}

if (email.HasHtmlBody() !== true) {
    console.log("This message has no HTML body.");
    return;
}

success = email.UnpackHtml("workshop-preview","index.html","images");
if (success !== true) {
    console.log(email.LastErrorText);
    return;
}

console.log("Saved workshop-preview/index.html and its related files.");