Get Outlook Mail Message: need "sender" filter and multiple filter samples

Hi everyone,

I’ve had no luck trying to filter based on the sender’s email address or multiple filters and I’ve wasted so much time trying different examples and searching for solutions.

Note: I’ve run the activity with no filters and I get all the emails in the folder.

Looking at one of the emails, I get:
messages(0).SenderEmailAddress → “[Blah@bling.org]”
messages(0).Sender → [“Blah” Blah@bling.org]
messages(0).From-> [“Blah” Blah@bling.org]

In the activity’s “Filter” field for sender’s email address I’ve tried:
[Sender] = ‘Blah.bling.org
[sender] = ‘blah.bling.org
sender:blah.bling.org
sender:blah (Note: this format works for searching by subject)
[Sender] = ‘blah’
[sender] = ‘blah’
The same as above using SenderEmailAddress as well as From

Can anyone provide me with a definitive working example of filtering by the sender’s email address? I need to do it within the activity instead of getting all the emails and looping through them.

Secondly, I’m looking for an example of multiple filters. Following on the above, I’m looking for a definitive working example will filter by both the sender AND the subject. I need to do it within the activity instead of getting all the emails and looping through them.

eg:
Subject contains “test” and sender email address is “blah@bling.org
where an email from “blah@bling.org” with the subject is “This is a test” will be returned.

Thank you

Hi @carlor - Could you please try this…

“@SQL=”“http://schemas.microsoft.com/mapi/proptag/0x0037001f”" like ‘Your Search String’ AND urn:schemas:httpmail:fromemail = ‘Your From Email Address’"

Tested Pattern:

“@SQL=”“http://schemas.microsoft.com/mapi/proptag/0x0037001f”" like ‘%Your Daily Digest%’ AND urn:schemas:httpmail:fromemail = ‘USPSInformeddelivery@informeddelivery.usps.com’"

Tested Result:

image

Note: When you copy paste Single and Double quotes will change to regular ones, so you have to modify it to Straight Single quote and Straight double quotes

1 Like

Hi @carlor
In addition to what @prasath17 said.

Try this way to filter mails by linq query

Like in get outlook mail activity store the output of this activity in mail_list variable which store the list of all mail messages in the outlook

now use the below assign activity for performing the linq query

mail_list=mail_list.Where(Function(mail) mail.Subject.Contains(your word) And mail.SenderEmailAddress.Equals(mailaddress) ).ToList

where your word and mailaddress are the the data by which u need to filter the data.

by this u can able to filter too.

Check this workflow for your reference

Main.xaml (7.4 KB)

Hope it helps you

Regards

Nived N

Happy Automation

2 Likes

Thank you for your example, but I need to be able to do the filtering within the Get Mail activity.

I’m having trouble with your sample. It could be the quotes, as you mentioned, but I haven’t been able to get the proper syntax. I keep getting an error. Could you include your xaml?

Thank you,

Carlo.

@carlor - Here you go Outlook_Filter_Carlor.zip (36.8 KB)

Thank you. That helped a BIT. Using the complete filter doesn’t work. I stripped out the email part of the filter and I managed results. I stripped out the subject part and left the email but no results were returned. I changed the ‘=’ to a ‘like’ with the email and that didn’t work. I then used ‘like’ with just ‘%Carlo%’ and I managed to get results.

Unfortunately, I need to be able to specify a complete email address. Any thoughts on what might be going on here? If I look at the From field for a returned email, it shows “Carlo Robazza <Carlo.Robazza@…>”

Thanks,

Carlo.

@carlor - Sorry I am not following you. The example which I gave I had the complete email address and it is working well. Can you please share your filter (after hiding PII information)??

This is my filter:
“@SQL=”“http://schemas.microsoft.com/mapi/proptag/0x0037001f”" like ‘%test%’ AND urn:schemas:httpmail:fromemail = ‘Carlo.Robazza@blah.ca’"

And this is a screenshot of the activity.