search key meaning 'allreturns all messages in the folder you may run into imaplib size limits if you request all the messages in large folder see "size limitson page 'before date''on date''since datethese three search keys returnrespectivelymessages that were received by the imap server beforeonor after the given date the date must be formatted like -jul- alsowhile 'since -jul- will match messages on and after july 'before -jul- will match only messages before july but not on july itself 'subject string''body string''text stringreturns messages where string is found in the subjectbodyor eitherrespectively if string has spaces in itthen enclose it with double quotes'text "search with spaces"'from string''to string''cc string''bcc stringreturns all messages where string is found in the "fromemail address"toaddresses"cc(carbon copyaddressesor "bcc(blind carbon copyaddressesrespectively if there are multiple email addresses in stringthen separate them with spaces and enclose them all with double quotes'cc "firstccexample com secondcc@example com"'seen''unseenreturns all messages with and without the \seen flagrespectively an email obtains the \seen flag if it has been accessed with fetch(method call (described lateror if it is clicked when you're checking your email in an email program or web browser it' more common to say the email has been "readrather than "seen,but they mean the same thing 'answered''unansweredreturns all messages with and without the \answered flagrespectively message obtains the \answered flag when it is replied to 'deleted''undeletedreturns all messages with and without the \deleted flagrespectively email messages deleted with the delete_messages(method are given the \deleted flag but are not permanently deleted until the expunge(method is called (see "deleting emailson page note that some email providers automatically expunge emails 'draft''undraftreturns all messages with and without the \draft flagrespectively draft messages are usually kept in separate drafts folder rather than in the inbox folder 'flagged''unflaggedreturns all messages with and without the \flagged flagrespectively this flag is usually used to mark email messages as "importantor "urgent 'larger ''smaller nreturns all messages larger or smaller than bytesrespectively 'not search-keyreturns the messages that search-key would not have returned 'or search-key search-key returns the messages that match either the first or second search-key