Sample code for 30+ languages & platforms
Android™

Get POP3 Mailbox Info as XML

See more POP3 Examples

Demonstrates the Chilkat MailMan.GetMailboxInfoXml method, which returns an XML document describing the messages currently in the POP3 mailbox — including each message's UIDL and size in bytes. This example configures the POP3 connection and prints the listing.

Tip: XML parsing code for this result can be generated at Chilkat Tools.

Background: Before downloading, it is often useful to survey what's in the mailbox. This method combines POP3's UIDL listing (a stable unique ID per message) with LIST sizes into one XML result. With it you can decide which messages to fetch or delete by UIDL — for example skipping ones already processed, or targeting only messages above a certain size.

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);

    //  Demonstrates the MailMan.GetMailboxInfoXml method, which returns an XML document with
    //  information about the messages currently in the POP3 mailbox, including the UIDL and size
    //  (in bytes) of each message.

    CkMailMan mailman = new CkMailMan();

    //  Configure the POP3 server connection.
    mailman.put_MailHost("pop.example.com");
    mailman.put_MailPort(995);
    mailman.put_PopSsl(true);
    mailman.put_PopUsername("user@example.com");
    mailman.put_PopPassword("myPassword");

    //  Retrieve the mailbox listing as XML.
    String xmlInfo = mailman.getMailboxInfoXml();
    Log.i(TAG, xmlInfo);

    //  The returned XML looks similar to:
    //  
    //    <mailbox count="2" size="4786">
    //        <email uidl="UID22-1784216315" msgNum="1" size="2394" />
    //        <email uidl="UID23-1784216315" msgNum="2" size="2392" />
    //    </mailbox>
    //  
    //  XML parsing code for this result can be generated at Chilkat's online tool:
    //  https://tools.chilkat.io/xmlParse

    //  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
    //  connects and authenticates -- using the property settings above -- whenever a server
    //  operation requires it.  Calling the explicit connect/authenticate methods can still be
    //  helpful to determine whether a failure occurs while connecting or while authenticating.

  }

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