JavaScript Requires Chilkat v11.0.0+
JavaScript
Create an inline forward
See more Email Object Examples
Create a forward from a saved email, set the forwarding author and destination, and inspect the generated subject and body. Save the draft before submitting it to SMTP. To introduce the original with a separate cover note, use the attached-message example.
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 original = new CkEmail();
success = original.LoadEml("alternatives.eml");
if (success !== true) {
console.log(original.LastErrorText);
return;
}
var forward = new CkEmail();
success = original.ToForward(forward);
if (success !== true) {
console.log(original.LastErrorText);
return;
}
forward.From = "Workshop team <events@example.com>";
success = forward.AddTo("Coordinator","coordinator@example.net");
if (success !== true) {
console.log(forward.LastErrorText);
return;
}
console.log(forward.Subject);
if (forward.HasHtmlBody() == true) {
console.log(forward.GetHtmlBody());
}
else {
console.log(forward.GetPlainTextBody());
}
success = forward.SaveEml("forward.eml");
if (success !== true) {
console.log(forward.LastErrorText);
return;
}
console.log("Saved forward.eml.");