JavaScript Requires Chilkat v11.0.0+
JavaScript
List message headers in their original field order
See more Email Object Examples
Walk the top-level header fields by index. Read the name and value at the same index so repeated fields such as Received retain their separate values. Attachment headers belong to the attachmentâs MIME part.
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 i = 0;
while ((i < email.NumHeaderFields)) {
// Read the value by index because names can repeat.
console.log(email.GetHeaderFieldName(i) + ": " + email.GetHeaderFieldValue(i));
i = i+1;
}