Search mail with date and domains - outlook

Hi All,
I want to find/search for all unread emails received the last 24 hours and have a sender domain like "" or ""

The received emails may come from different domains and only a couple of them are to be searched. Therefore, I would like to read an excel sheet with domains to be searched so I need to have a dynamic filter. How is the best way to do this?

Lets say my xls-sheet have three domains:,, The inbox contains emails from a lot of different domains but I want only filter on these three domains in the xls.
Should I read the excel and create a loop that creates a string to be saved in a variable? Then use the variable in the filter?: “[ReceivedTime]>=’ “+ Now.AddDays(-1).ToString(“yyyy-MM-dd HH:mm”) +”’” AND vVariableWithDomains

Dont know the syntax but something like this within the variable:
vVariableWithDomains = “[From]= * OR [From]= * OR [From]= *

Any suggestions how to do this?

No one out there with a suggestion?

I hope you can’t give like that.
At one time you can able to read one mail messages only.
Arivu :slight_smile:


I believe after you use an activity to read in your MailMessages you can use a filter method with .Where (which is what I use).

Let’s assume your MailMessages variable is maillist
maillist.Headers will give you a list contained in the email and I think maillist.Headers(0) or maillist.Headers(“Date”) will give you the date.

Here is an example for one sender (also works if you use a For each sender):

maillist.Where(Function(m) m.From.ToString.ToUpper.Contains("SENDER") and CDate(m.Headers("Date").ToString)>=Now.AddDays(-1) ).ToArray

So for multiple senders you can either add in additional conditions with OR
or you can use a list of senders:
In this case, let’s assume dt is the datatable containing the senders and we can use some

maillist.Where(Function(m) Array.IndexOf(dt.AsEnumerable.Select(Function(r) r(0).ToString.Trim.ToUpper).ToArray,m.From.ToString.ToUpper) > -1 and CDate(m.Headers("Date").ToString)>=Now.AddDays(-1) ).ToArray

So in the above it checks if the From has an index over 0 from the Array of senders in column A.

Now, you can process for the filtered list of mailmessages.

I apologize if there are some errors cause I did not test these examples in this post.



ok thanks I will try this.

What is the correct syntax if I want to use the filter property in “get outlook mail” and search for only one sender?

Isn’t there a “[FROM]=’*’”?


ok. I found a list of properties that may be used in the filter. Now I need to find out how can use a wildcard in the filter. If possible.

This works:
"[ReceivedTime]>=’ “+ Now.AddDays(-1).ToString(“yyyy-MM-dd HH:mm”) +”’ AND [senderemailaddress] = ‘’ "

I would like to do something like this:
[senderemailaddress] = ‘*’ " or [senderemailaddress] LIKE ‘’ "

Any thoughts?

1 Like

Try something like this in filter. This worked for me in the past for outlook 2010, bad news is for senderemailaddress I always got 0 rows. You can play around if you want.

"@SQL= urn:schemas:httpmail:sendername like '%xyz%'"

"@SQL= urn:schemas:httpmail:subject like '%xyz%'"

Thanks! This works but not for senderemailddress as you already pointed out.
I getting frustrated. I cant even filter on mails with attachments.

try these filters

  1. Email Addresses

"@SQL="+Chr(34)+""+Chr(34)+" like ''"

  1. Attachments

"@SQL= urn:schemas:httpmail:hasattachment=true"

If #1 works and you have to combile #1 and #2, answer is no idea.

After #1, you can do below in foreach loop.

emails.Where(Function(s) s.Attachments.Any)

Thanks for your help!
Either #1 or #2 works - it seems that the filter don’t work at all so the response contains all emails in the folder.

This works fine so I must find a way to handle it in another way…:

"[ReceivedTime]>=’ “+ Now.AddDays(-2).ToString(“yyyy-MM-dd HH:mm”) +” ’ AND [senderemailaddress] = ‘’ "


I have a bit similar topic:
I try to filter mails in the inbox by using the subject of the mails and the activity “IF” and the “variable 1” which is a date with format MM/DD/YYYY 00:00

if: mail.Subject.contains(Variable1)
Then : Message box:yes
Else: Message box: No

The result is anomaly always “No” even if when it should be “Yes”

Any support or suggestion ?

Thanks in advance