-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutlookNotify.py
More file actions
23 lines (19 loc) · 807 Bytes
/
outlookNotify.py
File metadata and controls
23 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import win32com.client
import pythoncom
class Handler_Class(object):
def OnNewMailEx(self, receivedItemsIDs):
senderList = ['', '', '', ''] #give the sender name those are imprtant for you
for ID in receivedItemsIDs.split(","):
# https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem_properties.aspx
mailItem = outlook.Session.GetItemFromID(ID)
#senderId = mailItem.SenderEmailAddress
senderName = mailItem.SenderName
print ("Subj: " + mailItem.Subject)
print ("SenderName: " + senderName)
if(senderName in senderList):
print('\007')
print("Important Mail")
print ("========")
outlook = win32com.client.DispatchWithEvents("Outlook.Application", Handler_Class)
#and then an infinit loop that waits from events.
pythoncom.PumpMessages()