Search code examples
.netvb.netoutlookexchange-server

Restrict items to Exchange senders


I need to filter Outlook items by email address.

I found the answer here:

Filter = "@SQL=urn:schemas:httpmail:fromemail Like '%[email protected]%'"

but it doesn't work if the sender is using Exchange. Maybe some different schema? I've searched the docs but can't find the answer.

Edit, to clarify, how that string is used:

Dim items As Outlook.Items = folder.Items.Restrict(Filter)

Solution

  • Use a restriction on SenderEmailType being "EX".

    The filter would be either [SenderEmailType] = 'EX' or @SQL="http://schemas.microsoft.com/mapi/proptag/0x0C1E001F" = 'EX'