How can I find out what messages are marked for deletion (the expunge action)?

John Zukowski

You need to attach a MessageChangedListener to the folder. Then, in the messageChanged() method, you can find out if/when the flags changed. You'll have to check specifically if the deleted flag is set, or assuming that's the only one you are changing, you don't. The following listener is basically what you need:

// Attach listener
MessageChangedListener listener = 
    new MessageChangedListener() {
  public void messageChanged(MessageChangedEvent e) {
    try {
      Message m = e.getMessage();
      System.out.println("Flagged: " + m.getSubject());
      int type = e.getMessageChangeType();
      System.out.println("	Flags Changed? " + 
        (type == MessageChangedEvent.FLAGS_CHANGED));
    } catch (MessagingException me) {
      System.out.println("Oops: " + me);
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact