diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index f13c91294d..e5dc2e7240 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -42,6 +42,7 @@ import androidx.preference.PreferenceManager; import com.sun.mail.iap.BadCommandException; import com.sun.mail.iap.CommandFailedException; import com.sun.mail.iap.ConnectionException; +import com.sun.mail.iap.ProtocolException; import com.sun.mail.iap.Response; import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPMessage; @@ -1711,9 +1712,16 @@ class Core { // This is done outside of JavaMail to prevent changed notifications if (!ifolder.isOpen()) throw new FolderClosedException(ifolder, "UID FETCH"); + MessagingException ex = (MessagingException) ifolder.doCommand(new IMAPFolder.ProtocolCommand() { @Override public Object doCommand(IMAPProtocol protocol) { + try { + protocol.select(folder.name); + } catch (ProtocolException ex) { + return new MessagingException("UID FETCH", ex); + } + // Build ranges List> ranges = new ArrayList<>(); long first = -1;