Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import imaplib
- HOST = "imap.gmail.com"
- USER = "tbarik@ncsu.edu"
- PASSWORD = "---"
- BATCH_FOLDER = "Batch"
- INBOX_FOLDER = "\\Inbox"
- def batch_mail():
- server = imaplib.IMAP4_SSL(HOST)
- server.login(USER, PASSWORD)
- server.select(BATCH_FOLDER)
- typ, [msg_uids] = server.uid("SEARCH", "ALL")
- msg_uids = msg_uids.replace(' ', ',')
- if msg_uids:
- server.uid("STORE", msg_uids, "+X-GM-LABELS", INBOX_FOLDER)
- server.uid("STORE", msg_uids, "+FLAGS.SILENT", r"(\Deleted)")
- server.uid("EXPUNGE", msg_uids)
- print msg_uids
- return msg_uids
- # noinspection PyUnusedLocal
- def lambda_handler(event, context):
- return batch_mail()
- if __name__ == '__main__':
- batch_mail()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement