Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import imaplib
  2.  
  3. HOST = "imap.gmail.com"
  4. USER = "tbarik@ncsu.edu"
  5. PASSWORD = "---"
  6.  
  7. BATCH_FOLDER = "Batch"
  8. INBOX_FOLDER = "\\Inbox"
  9.  
  10.  
  11. def batch_mail():
  12. server = imaplib.IMAP4_SSL(HOST)
  13. server.login(USER, PASSWORD)
  14. server.select(BATCH_FOLDER)
  15.  
  16. typ, [msg_uids] = server.uid("SEARCH", "ALL")
  17. msg_uids = msg_uids.replace(' ', ',')
  18.  
  19. if msg_uids:
  20. server.uid("STORE", msg_uids, "+X-GM-LABELS", INBOX_FOLDER)
  21.  
  22. server.uid("STORE", msg_uids, "+FLAGS.SILENT", r"(\Deleted)")
  23. server.uid("EXPUNGE", msg_uids)
  24.  
  25. print msg_uids
  26. return msg_uids
  27.  
  28.  
  29. # noinspection PyUnusedLocal
  30. def lambda_handler(event, context):
  31. return batch_mail()
  32.  
  33.  
  34. if __name__ == '__main__':
  35. batch_mail()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement