Android™
Android™
Compare Two Emails by UIDL
See more Email Object Examples
Demonstrates the Chilkat Email.UidlEquals method, which returns true if this email's UIDL equals the UIDL of the email passed as the argument. The comparison is meaningful for messages obtained through POP3. This example gives two emails the same UIDL and compares them.
Background: A POP3 UIDL is a stable, unique identifier a server assigns to each message in a mailbox. Comparing UIDLs is how a client decides whether two message references point to the same server message — the basis for "leave messages on server" logic, where an app downloads a message once and skips it on later checks by remembering its UIDL.
Chilkat Android™ Downloads
// 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);
// Demonstrates the UidlEquals method, which returns true if this email's UIDL equals the
// UIDL of the email passed as the argument. UIDLs are POP3 message identifiers.
CkEmail email1 = new CkEmail();
email1.AddHeaderField("X-UIDL","0000000123abcdef");
CkEmail email2 = new CkEmail();
email2.AddHeaderField("X-UIDL","0000000123abcdef");
// Compare the two emails' UIDLs.
boolean eq = email1.UidlEquals(email2);
if (eq == true) {
Log.i(TAG, "The two emails have the same UIDL.");
}
else {
Log.i(TAG, "The two emails have different UIDLs.");
}
}
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."
}
}