Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from imapclient import IMAPClient
- HOST = 'imap.gmail.com'
- USERNAME = '***yourGMAILusername***'
- PASSWORD = '***yourGMAILpassword***'
- ssl = True
- FOLDER = 'INBOX'
- ### The default is to scan your Inbox. Uncomment the line below if you want
- ### to scan all of your mail. It could take >5min to scan all of your email.
- # FOLDER = '[Gmail]/All Mail'
- SIZETHRESHOLD = 10000000
- ### Scan for files larger than the number above (in bytes; 10Mb is reasonable to start with)
- server = IMAPClient(HOST, use_uid=True, ssl=ssl)
- server.login(USERNAME, PASSWORD)
- select_info = server.select_folder(FOLDER)
- print '%d messages in %s' % (select_info['EXISTS'], FOLDER)
- print
- print "Messages:"
- criteria='LARGER %d' %SIZETHRESHOLD
- messages = server.search([criteria])
- response = server.fetch(messages, ['RFC822.SIZE', 'ENVELOPE'])
- for msgid, data in response.iteritems():
- if data['RFC822.SIZE'] > SIZETHRESHOLD :
- envelope = list(data['ENVELOPE'])
- sender = list(envelope[2][0])
- print ' ID %d: ' % msgid
- print ' From: %s <%s@%s>' % (sender[0], sender[2], sender[3])
- print ' Subject: %s ' % envelope[1]
- print ' Size: %i' % data['RFC822.SIZE']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement