JavaScript Requires Chilkat v11.0.0+
JavaScript
Build To, Cc, and Bcc recipient lists
See more Email Object Examples
Use a name and address for one recipient, or pass a comma-separated mailbox list to an AddMultiple method. Both forms append recipients. Clear the relevant list before replacing it. Inspect counts before handing the message to your sending code.
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.AddTo("Lead organizer","lead@example.net");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = email.AddMultipleTo("Alex <alex@example.net>, Pat <pat@example.net>");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = email.AddCC("Editor","editor@example.net");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = email.AddMultipleCC("review@example.net, support@example.net");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
// Blind copies are kept on the object for SMTP envelope delivery.
email.UncommonOptions = "NoBccHeader";
success = email.AddBcc("Archive","archive@example.com");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = email.AddMultipleBcc("records@example.com, audit@example.com");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
console.log("To: " + email.NumTo + " Cc: " + email.NumCC + " Bcc: " + email.NumBcc);