1

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?

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
Amit Pathak
  • 1,145
  • 11
  • 26

1 Answers1

3

You need to include multiple conditions using the OR operator:

" ([SenderEmailAddress] = 'abc@xyz.com' ) or ([SenderEmailAddress] = 'mno@xyz.com') "
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78