JavaScript Requires Chilkat v11.0.0+
JavaScript
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.
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.
var success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
var email = new CkEmail();
success = email.LoadEml("message.eml");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
var mimeBytes = new CkBinData();
success = email.GetMimeBd(mimeBytes);
if (success !== true) {
console.log(email.LastErrorText);
return;
}
var mime = new CkMime();
success = mime.LoadMimeBd(mimeBytes);
if (success !== true) {
console.log(mime.LastErrorText);
return;
}
console.log(mime.GetStructure("text"));