Sample code for 30+ languages & platforms
JavaScript Requires Chilkat v11.0.0+

Inspect blind-copy recipients and prepare a shareable copy

See more Email Object Examples

Keep the addressed Email object for SMTP submission. When exporting a copy to share, clear its Bcc collection before saving. Treat intermediate MIME buffers as private because a renderer can preserve blind-copy details.

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.
JavaScript
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 = "Your workshop confirmation.";
success = email.AddBcc("Archive","archive@example.com");
if (success !== true) {
    console.log(email.LastErrorText);
    return;
}

var i = 0;
while ((i < email.NumBcc)) {
    console.log("Envelope blind copy: " + email.GetBccAddr(i));
    i = i+1;
}

//  Keep the original delivery list intact. Remove blind copies from the export.
var rendered = new CkBinData();
success = email.GetMimeBd(rendered);
if (success !== true) {
    console.log(email.LastErrorText);
    return;
}

var copy = new CkEmail();
success = copy.SetFromMimeBd(rendered);
if (success !== true) {
    console.log(copy.LastErrorText);
    return;
}

copy.ClearBcc();
success = copy.SaveEml("shareable.eml");
if (success !== true) {
    console.log(copy.LastErrorText);
    return;
}

console.log("Bcc entries in shareable copy: " + copy.NumBcc);