Sample code for 30+ languages & platforms
Java

Clear the Bcc Recipients of an Email

See more Email Object Examples

Demonstrates the Chilkat Email.ClearBcc method, which clears the list of blind carbon-copy (Bcc) recipients. It changes only the current in-memory email object and does not affect messages already sent. This example adds two Bcc recipients, clears them, and prints the count before and after.

Background: Reusing one Email object as a template for several messages is common — you set the subject and body once and vary the recipients. Clearing methods like ClearBcc, ClearCC, and ClearTo let you reset one recipient list between sends without rebuilding the whole message, so a stray Bcc from a previous send does not leak into the next.

Chilkat Java Downloads

Java
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[])
  {
    //  Demonstrates the ClearBcc method, which clears the list of blind carbon-copy (Bcc)
    //  recipients.  This changes only the current email object.

    CkEmail email = new CkEmail();

    email.AddBcc("Joe","joe@example.com");
    email.AddBcc("Jane","jane@example.com");
    System.out.println("NumBcc before clear = " + email.get_NumBcc());

    //  Remove all Bcc recipients.
    email.ClearBcc();

    System.out.println("NumBcc after clear = " + email.get_NumBcc());
  }
}