Sample code for 30+ languages & platforms
Android™

Check Whether an Email Is a multipart/report

See more Email Object Examples

Demonstrates the Chilkat Email.IsMultipartReport method, which returns true when the top-level message structure is a multipart/report (such as a bounce/DSN or a read receipt/MDN). This example loads an email and reports whether it is a multipart/report.

Background: Automated mail — delivery failures and read receipts — arrives wrapped in the multipart/report structure, which carries machine-readable report parts. Detecting it with IsMultipartReport is the first step in a bounce-handling pipeline: once you know a message is a report, you can pull its parts with GetReport or read delivery fields with GetDeliveryStatusInfo to act on failures automatically.

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;

    //  Demonstrates the IsMultipartReport method, which returns true if the top-level message
    //  structure is a multipart/report (such as a bounce / DSN or a read receipt / MDN).

    CkEmail email = new CkEmail();

    success = email.LoadEml("qa_data/eml/dsn_bounce.eml");
    if (success == false) {
        Log.i(TAG, email.lastErrorText());
        return true;
        }

    if (email.IsMultipartReport() == true) {
        Log.i(TAG, "This email is a multipart/report (e.g. a bounce or read receipt).");
        }
    else {
        Log.i(TAG, "This email is not a multipart/report.");
        }

    //  Note: The path "qa_data/..." is a relative local filesystem path,
    //  relative to the current working directory of the running application.

  }

  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."
  }
}