How to Filter with Domain in Get Outlook Mail Message activity?

My requirement is I want to read email only by specific email id e.g. @gmail.com. If there are 20 Unread emails and say out of which 4 are @gmail.com then BOT should only read those 4 emails.

Please help me on this.

Thank you.

Hey,
to check from which email address message has been sent, robot has to get that email firstly.
But in ‘for each’ activity you can use ‘if’ statement and check the sender → message.From.ToString
and with these messages you can do something later

1 Like

Hi,

Thanks for your reply but I want to filter emails before reading. Is it possible ?

We have filter options in Get Outlook Mail message activity so I want such filter code which will filter based on domain.

Try to use:
“[sendername]=‘Name of sender”
or
“[senderemailaddress] = ‘xxx@gmail.com’”
or
maybe this video will help you:

1 Like

Hi @Rahul_More1

Try out the below expression in Outlook!

“@SQL= (urn:schemas:httpmail:sendername like ‘%@gmail.com%’)”

Regards

Ok.
I think I found the solution in the different topic.
So I used for sender email address this filter:
“@SQL=”+Chr(34)+“http ://schemas.microsoft.com/mapi/proptag/0x007D001E”+Chr(34)+" like ‘%@gmail.com%’"
and it’s works well.
I found this solution here:

2 Likes

Hi,

Thanks for your reply.

I tried this but actually it’s not filtering.

In my mailbox I kept 5 unread emails and out of which two are Gmail domain, it should give me Two as an count but it is giving five count.

But did you get 5 last emails from domain @gmail.com ?
Since you are using a filter, it will skip all other messages (from different domains then gmail).
I don’t see any issue with using this filter expression :roll_eyes:

1 Like

Hi,

I mentioned earlier that there are 5 unread emails, out of which two are @gmail.com and other three are @uipath.com.

I used code sent by you and put condition for gmail.com, so generally it should give me count as TWO and rest emails i.e. @Uipath.com those should be in Unread condition but I am getting count as FIVE and all emails are getting read which unexpected.

Filtering doesn’t work that way.
If you want 2 unread message from gmail and you will use filter you will get 2 unread emails only from gmail (the order doesn’t matter and all emails from another domains will be skipped).
If you mark 5 you will get 5 unread and they will all be from gmail.

1 Like

You can try from your end. Take 6 emails 3 from @Uipath.com and 3 from @gmail.com. Keep all emails as Unread, then run your BOT keeping any one domain in filter condition.

Let me know the result :slightly_smiling_face:

I am sure that it will give you count as 6 instead of 3.

So, filtering is the bad way for you. It works well but it works like the where clause. This is reason why you get all messages from gmail.
So, summarize to get the results which you want you need to get the messages without filtering, then check the sender’s domain in the if condition and mark the message as read.

1 Like