a guest Oct 23rd, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- from win32com.client import Dispatch
- import re
- outlook = Dispatch("Outlook.Application").GetNamespace("MAPI")
- inbox = outlook.GetDefaultFolder("6")
- all_inbox = inbox.Items
- for message in all_inbox:
- name = str(message.subject)
- #to eliminate any special characters in the name
- name = re.sub('[^A-Za-z0-9\s\-]+', '', name)+'.msg'
- print("SUCCESSFUL","Message Saved")
- print("ERROR","Message failed to save")
RAW Paste Data