Sample code for 30+ languages & platforms
CkJava 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.

Chilkat CkJava Downloads

CkJava
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    CkEmail email = new CkEmail();
    email.put_From("Workshop team <events@example.com>");
    success = email.AddTo("Alex Rivera","alex@example.net");
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    email.put_Subject("Workshop registration");
    email.put_Body("Your workshop confirmation.");
    success = email.AddBcc("Archive","archive@example.com");
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    int i = 0;
    while ((i < email.get_NumBcc())) {
        System.out.println("Envelope blind copy: " + email.getBccAddr(i));
        i = i+1;
        }

    //  Keep the original delivery list intact. Remove blind copies from the export.
    CkBinData rendered = new CkBinData();
    success = email.GetMimeBd(rendered);
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    CkEmail copy = new CkEmail();
    success = copy.SetFromMimeBd(rendered);
    if (success != true) {
        System.out.println(copy.lastErrorText());
        return;
        }

    copy.ClearBcc();
    success = copy.SaveEml("shareable.eml");
    if (success != true) {
        System.out.println(copy.lastErrorText());
        return;
        }

    System.out.println("Bcc entries in shareable copy: " + copy.get_NumBcc());
  }
}