How can I find out what messages are marked for deletion (the expunge action)?
Created May 4, 2012
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); } } }; folder.addMessageChangedListener(listener);