diff --git a/app/src/main/java/com/sun/mail/imap/IMAPFolder.java b/app/src/main/java/com/sun/mail/imap/IMAPFolder.java index d069f27921..0fc71205b3 100644 --- a/app/src/main/java/com/sun/mail/imap/IMAPFolder.java +++ b/app/src/main/java/com/sun/mail/imap/IMAPFolder.java @@ -3644,8 +3644,9 @@ public class IMAPFolder extends Folder implements UIDFolder, ResponseHandler { long[] luid = UIDSet.toArray(uidset); Message[] msgs = createMessagesForUIDs(luid); for (Message m : msgs) { - if (m.getMessageNumber() > 0) - messageCache.expungeMessage(m.getMessageNumber()); + // Avoid creating seqnums + if (m != null) + ((IMAPMessage)m).setExpunged(true); } if (doExpungeNotification && hasMessageCountListener) { notifyMessageRemovedListeners(true, msgs); diff --git a/app/src/main/java/com/sun/mail/imap/MessageCache.java b/app/src/main/java/com/sun/mail/imap/MessageCache.java index 93811849ac..62ccc4adb8 100644 --- a/app/src/main/java/com/sun/mail/imap/MessageCache.java +++ b/app/src/main/java/com/sun/mail/imap/MessageCache.java @@ -217,8 +217,8 @@ public class MessageCache { int newnum = 1; while (oldnum <= size) { // is message expunged? - if (seqnumOf(oldnum) <= 0) { IMAPMessage m = getMessage(oldnum); + if (seqnumOf(oldnum) <= 0 || (m !=null && m.isExpunged())) { mlist.add(m); } else { // keep this message