JavaScript Requires Chilkat v11.0.0+
JavaScript
Inspect the MIME structure and contents of an EML file
See more Email Object Examples
Open the complete EML in Mime for a tree view and in Email for application-level collections. An HTML logo, downloadable file, attached message, and delivery report are counted separately. Try the complex workshop draft.
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("workshop.eml");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
var mime = new CkMime();
success = mime.LoadMimeFile("workshop.eml");
if (success !== true) {
console.log(mime.LastErrorText);
return;
}
console.log(mime.GetStructure("text"));
console.log("Subject: " + email.Subject);
console.log("Files: " + email.NumAttachments + " Related items: " + email.NumRelatedItems);
console.log("Attached messages: " + email.NumAttachedMessages + " Reports: " + email.NumReports);
var i = 0;
while ((i < email.NumAttachments)) {
console.log(email.GetAttachmentFilename(i) + " " + email.GetAttachmentContentType(i) + " " + email.GetAttachmentSize(i) + " bytes");
i = i+1;
}
i = 0;
while ((i < email.NumRelatedItems)) {
console.log("Related: " + email.GetRelatedFilename(i) + " " + email.GetRelatedContentType(i));
i = i+1;
}