I need an alternative for IMAP search command “A search 1:* unseen not deleted” since the email server is forbidding the search command. I tried using “A status (unseen)” but it always returns zero though there’s an unread message. Is there any alternative for the command? Thanks in advance.
Share
Is your problem that the IMAP server doesn’t support
SEARCHat all, or that it doesn’t like your particularSEARCHcommand? If it’s the latter, we can simplify:(as
1:*is implicit). Even simpler — just in case the server doesn’t like and-ingSEARCHterms together at all — would be:and logically doing the AND in your code.
The brute-force way of doing it is:
and then picking out all the ones with neither
\Seennor\Deleted. (I’m suggestingUID FETCHbecause a similarFETCHcommand will returnBADon an empty folder.)Also, you’re not supposed to call the
STATUScommand on the currently-selected folder: