Android™
Android™
Send a POP3 RSET to Unmark Deletions
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3Reset method, which sends the POP3 RSET command to the server. Any messages marked for deletion during the current session are unmarked and remain in the mailbox, and the POP3 session stays open. This example marks a message for deletion, then clears the mark with RSET.
Background:
RSET is POP3's in-session undo for deletion marks. It differs from Pop3EndSessionNoQuit, which also discards pending deletions but closes the connection. With RSET the authenticated session continues, so you can clear the marks and keep working — handy when a processing step fails partway and you want to retry without reconnecting.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);
boolean success = false;
// Demonstrates the MailMan.Pop3Reset method, which sends the POP3 RSET command. Any
// messages marked for deletion during the current session are unmarked and remain in the
// mailbox. The POP3 session stays open.
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");
success = mailman.Pop3BeginSession();
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
// Mark a message for deletion...
success = mailman.DeleteByMsgnum(1);
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
// ...then change your mind: RSET unmarks all pending deletions but keeps the session open.
success = mailman.Pop3Reset();
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
// Ending the session now commits nothing, because the marks were cleared.
success = mailman.Pop3EndSession();
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
Log.i(TAG, "Pending deletions were unmarked with RSET.");
}
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."
}
}