Nov 10, 2018

How to search Email by date through IMAP using Python

M is an instance of IMAP4.
See also:

Example of reading email from Gmail / Office 365 by IMAP using Python


M.search(None, '(SINCE "01-Jan-2015")')
M.search(None, '(BEFORE "01-Jan-2015")')
M.search(None, '(SINCE "01-Jan-2012" BEFORE "18-Jan-2015")')