I have IMAPFolderwith MessageCountListenerthat is listening posts that are added / deleted from the folder. Inside mine, messageRemoved(MessageCountEvent ...)I need to get the UID of the message that was just deleted so that I can reflect these changes in my local cache.
The problem is that if I try to execute IMAPFolder.getUID(Message ...)in a remote message, I get
javax.mail.MessageRemovedException
at com.sun.mail.imap.IMAPMessage.checkExpunged(IMAPMessage.java:220)
at com.sun.mail.imap.IMAPFolder.getUID(IMAPFolder.java:1949)
at (...).IdleWatcher$1.messagesRemoved(IdleWatcher.java:64)
at javax.mail.event.MessageCountEvent.dispatch(MessageCountEvent.java:152)
at javax.mail.EventQueue.run(EventQueue.java:134)
at java.lang.Thread.run(Thread.java:856)
How to determine the identifier of a deleted message? I could look at all cached messages and check which ones still exist, however this is a too resource-intensive process that needs to be done every time a message is deleted.
source
share