a guest Aug 10th, 2018 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import imaplib
- import email
- mail = imaplib.IMAP4_SSL('imap.gmail.com',993)
- user = 'firstname.lastname@example.org'
- pwd = 'xxxxx'
- print('successfully logged in')
- print('selecting inbox')
- print('inbox selected')
- # selecting all items / emails
- result, data = mail.uid('search', None, "ALL")
- # transforming tuple into list / splitting them
- inbox_item_list = data.split()
- result2, email_data = mail.uid('fetch', inbox_item_list, '(RFC822)')
- # using regex to search for emails?
- # safe results into csv
RAW Paste Data