Sample code for 30+ languages & platforms
Android™ 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 Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    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) {
        Log.i(TAG, email.lastErrorText());
        return;
        }

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

    int i = 0;
    while ((i < email.get_NumBcc())) {
        Log.i(TAG, "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) {
        Log.i(TAG, email.lastErrorText());
        return;
        }

    CkEmail copy = new CkEmail();
    success = copy.SetFromMimeBd(rendered);
    if (success != true) {
        Log.i(TAG, copy.lastErrorText());
        return;
        }

    copy.ClearBcc();
    success = copy.SaveEml("shareable.eml");
    if (success != true) {
        Log.i(TAG, copy.lastErrorText());
        return;
        }

    Log.i(TAG, "Bcc entries in shareable copy: " + String.valueOf(copy.get_NumBcc()));

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}