I'm looking for an IMAP search clause to get GMail's "[Gmail]/All Mail" contents but filter out mails which are in "[Gmail]/Drafts".
IMAP DRAFT flag doesn't help with GMail's IMAP. By comparing full headers, I've noticed that drafts don't have value in "Delivered-To" field - it's missing from the header for all messages in "[Gmail]/Drafts".
I've tried UID search directly on "[Gmail]/Drafts" which has a few messages with following clause/results:
I'm expecting to get a clause which returns no messages - or all messages which have Delivered-To absent:
(HEADER Delivered-To "") <- returns all drafts
(NOT (HEADER Delivered-To "")) <- negating still returns all drafts!
(NOT HEADER Delivered-To "") <- still returns all drafts
(HEADER Delivered-To NIL) <- returns no messages - opposite to expected
(NOT (HEADER Delivered-To NIL)) <- returns all drafts
(NOT HEADER Delivered-To NIL) <- returns all drafts
(NOT (DRAFT)) <- returns all drafts
(DRAFT) <- returns none - opposite to expected, GMail doesn't seem to flag drafts with DRAFT
Will appreciate suggestions for how would you formulate "HEADER Delivered-To is not empty" for GMail IMAP.
Though not a direct answer, I ended up downloading bodies of new messages and scanning them for flags.