At the moment I am using the below code to listen to incoming messages in Outlook from Python.
How can I do the same for Outgoing messages from my Outlook?
import win32com.client
import pythoncom
class Handler_Class(object):
senders = ['blabla@gmail.com']
def OnNewMailEx(self, receivedItemsIDs):
# RecrivedItemIDs is a collection of mail IDs separated by a ",".
# You know, sometimes more than 1 mail is received at the same moment.
for ID in receivedItemsIDs.split(","):
mail = outlook.Session.GetItemFromID(ID)
subject = mail.Subject
outlook = win32com.client.DispatchWithEvents("Outlook.Application",Handler_Class)
# an infinite loop that waits for event
pythoncom.PumpMessages()