my goal is to use a python script to trigger an event handler whenever I open up an email on Outlook, from there I should be able to get the data of the email that was opened, then do something with the data. There is a similar thread on how to do it via VBA (here), but I can't figure out how to translate that to python using win32com.
I have looked through the microsoft docs but can't figure out how to trigger events on MailItem objects. https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem
The closest I had come to doing something close was by doing something like the below, which is probably not the solution as item in this case(as the doc states) does not contain the data.
import win32com.client
import pythoncom
import re
class Handler_Class(object):
def OnItemLoad(self, item):
print(item.Class)
outlook = win32com.client.DispatchWithEvents("Outlook.Application",Handler_Class)
Any ideas/suggestions appreciated! Thanks in advance!