Skip to content

Instantly share code, notes, and snippets.

@mjs
Created May 17, 2017 09:52
Show Gist options
  • Save mjs/e50dc58938691d39faf7c4eeacc23323 to your computer and use it in GitHub Desktop.
Save mjs/e50dc58938691d39faf7c4eeacc23323 to your computer and use it in GitHub Desktop.
imap = imapclient.IMAPClient(server)
imap.login(username, getpass())
imap.select_folder('INBOX')
messages = imap.search(['NOT', 'DELETED'])
for message_id, data in imap.fetch(messages, ['RFC822']).iteritems():
body = data['RFC822']
# do stuff with message_id and body...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment