I am trying to read emails received from specific email addresses (more than 1). For single use case, the following code seems to be working -
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items.Restrict("[SenderEmailAddress] = 'abc@xyz.com' ")
For providing multiple email ID as a filter I tried the following two approaches but that does not work -
messages = inbox.Items.Restrict("[SenderEmailAddress] = 'abc@xyz.com; mno@xyz.com' ")
messages = inbox.Items.Restrict("[SenderEmailAddress] In ['abc@xyz.com', 'mno@xyz.com'] ")
How can I provide multiple filter values like in this scenario?
You need to include multiple conditions using the OR
operator:
" ([SenderEmailAddress] = 'abc@xyz.com' ) or ([SenderEmailAddress] = 'mno@xyz.com') "