JavaScript Requires Chilkat v11.0.0+
JavaScript
Set a MIME header on one attachment
See more Email Object Examples
Add a file using the content type required by the receiving application. Set Content-Description on the newly added MIME part and read it back from that part. The message-level headers have a separate collection.
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();
email.From = "Workshop team <events@example.com>";
success = email.AddTo("Alex Rivera","alex@example.net");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
email.Subject = "Workshop registration";
email.Body = "Attached is the requested data file.";
success = email.AddFileAttachment2("sample.hpm","application/x-hprimnet");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
var index = email.NumAttachments - 1;
email.AddAttachmentHeader(index,"Content-Description","HPM/3.0");
console.log(email.GetAttachmentHeader(index,"Content-Description"));
success = email.SaveEml("described-attachment.eml");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
console.log("Saved described-attachment.eml.");