I'm trying to filter the MailItem
I extracted from outlook using pywin32.
I can filter on the sender email address just fine but i can't seem to find the proper filter to use for recipients (the "To" field in the mail).
def parse_mail():
global mail_MIs
pythoncom.CoInitialize()
outlook = Client.Dispatch("outlook.Application")
namespace = outlook.GetNamespace('MAPI')
inbox = namespace.Folders('bla@blabla.com').Folders('Inbox')
# Get an instance of the 2022 folder
year2022_folder = inbox.Folders[1].Folders
for month_folder in year2022_folder:
for item in month_folder.Items.Restrict("[SenderEmailAddress] = 'test1@test.com' OR [SenderEmailAddress] = 'test2@test.com'"):
# Any operation i need to do
I tried using "[To]" as a filter; but it did not work. Also i can't seem to find any proper list on what other filters i can use with the Restrict method even in the Microsoft documentation.