Node.js Requires Chilkat v11.0.0+
Node.js
Export HTML with related images embedded as data URLs
See more Email Object Examples
Read inline-image.eml and produce a single UTF-8 HTML file with its related images embedded. This is useful for a self-contained preview. Treat HTML from received mail as untrusted when displaying it.
Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
var email = new chilkat.Email();
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;
}
var html = new chilkat.StringBuilder();
success = email.GetHtmlBodySb(true,html);
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = html.WriteFile("preview.html","utf-8",false);
if (success !== true) {
console.log("Failed: html.WriteFile.");
return;
}
console.log("Saved preview.html.");
}
chilkatExample();