IMAP Query Syntax
To combine multiple keywords enclose the query in brackets,
e.g. the following matchess all unseen emails received from address sender-email@example.com with subject the subject:
(FROM "sender-email@example.com" SUBJECT "the subject" UNSEEN)
Keywords
Section titled “Keywords”All messages in the mailbox; the default initial key forANDing.ANSWERED
Section titled “ANSWERED”Messages with the \Answered flag set.Messages that contain the specified string in the envelopestructure's BCC field.BEFORE
Section titled “BEFORE”Messages whose internal date (disregarding time and timezone)is earlier than the specified date.Messages that contain the specified string in the body of themessage.Messages that contain the specified string in the envelopestructure's CC field.DELETED
Section titled “DELETED”Messages with the \Deleted flag set.Messages with the \Draft flag set.FLAGGED
Section titled “FLAGGED”Messages with the \Flagged flag set.Messages that contain the specified string in the envelopestructure's FROM field.HEADER
Section titled “HEADER”Messages that have a header with the specified field-name (asdefined in [RFC-2822]) and that contains the specified stringin the text of the header (what comes after the colon). If thestring to search is zero-length, this matches all messages thathave a header line with the specified field-name regardless ofthe contents.KEYWORD
Section titled “KEYWORD”Messages with the specified keyword flag set.LARGER
Section titled “LARGER”Messages with an [RFC-2822] size larger than the specifiednumber of octets.Messages that have the \Recent flag set but not the \Seen flag.This is functionally equivalent to "(RECENT UNSEEN)".Messages that do not match the specified search key.Messages that do not have the \Recent flag set. This isfunctionally equivalent to "NOT RECENT" (as opposed to "NOTNEW").Messages whose internal date (disregarding time and timezone)is within the specified date.Messages that match either search key.RECENT
Section titled “RECENT”Messages that have the \Recent flag set.Messages that have the \Seen flag set.SENTBEFORE
Section titled “SENTBEFORE”Messages whose [RFC-2822] Date: header (disregarding time andtimezone) is earlier than the specified date.SENTON
Section titled “SENTON”Messages whose [RFC-2822] Date: header (disregarding time andtimezone) is within the specified date.SENTSINCE
Section titled “SENTSINCE”Messages whose [RFC-2822] Date: header (disregarding time andtimezone) is within or later than the specified date.Messages whose internal date (disregarding time and timezone)is within or later than the specified date.SMALLER
Section titled “SMALLER”Messages with an [RFC-2822] size smaller than the specifiednumber of octets.SUBJECT
Section titled “SUBJECT”Messages that contain the specified string in the envelopestructure's SUBJECT field.Messages that contain the specified string in the header orbody of the message.Messages that contain the specified string in the envelopestructure's TO field.Messages with unique identifiers corresponding to the specifiedunique identifier set. Sequence set ranges are permitted.UNANSWERED
Section titled “UNANSWERED”Messages that do not have the \Answered flag set.UNDELETED
Section titled “UNDELETED”Messages that do not have the \Deleted flag set.UNDRAFT
Section titled “UNDRAFT”Messages that do not have the \Draft flag set.UNFLAGGED
Section titled “UNFLAGGED”Messages that do not have the \Flagged flag set.UNKEYWORD
Section titled “UNKEYWORD”Messages that do not have the specified keyword flag set.UNSEEN
Section titled “UNSEEN”Messages that do not have the \Seen flag set.