Reading emails from list of email address specified

I have a list of email addresses, bot has to read only those emails from inbox which has been sent from those specific email addresses in the email list. The sender has to be from the email list specified. I’m using the get exchange mail message activity to read emails.
How can this be achieved?

@automated

you can use the below linq query in assign

filteredmails = lstmails.Where(function(x) arr.Any(function(y) y.ToLower.Equals(x.From.Address.ToLower))

lstmails is the output og get mails and arr is the array of email addresses

you can as well try this in filtered directly

"from:"" + String.Join(arr,""" OR from:""") + """

cheers

How does the direct filter condition work, kindly elaborate, it seems to have an error .
Thanks.

@automated

I am using all values from array creating or function

What error are you getting?

Did you face any issue with linq

Cheers

are u use outlook activities ? just check out the documentation Activities - Get Outlook Mail Messages
and u can use the fillter with the value :
“[SenderName] = ‘Anthony Young’”
“[From] = ‘Anthony Young’”

Hi,
I have to use 15 whitelisted email addresses and only consider emails for processing if the sender is among them.

we use the term allow list and of opposite deny list / block list

Hi @Anil_G
I’m using arr as String array to store emails, and lstmails is List datatype. What type should I use for filteredmails variable?

How can I handle the mismatch.

This shows you how to do email query filters:

And based on this post:

…I was able to determine that the way to query based on sender is:

(from/emailAddress/address) eq 'some.sender@gmail.com'

So if you have a list of email addresses you need to loop through them and build the query…

  • For Each in yourStringArray
    ** Assign queryString = queryString + if(queryString="",""," or ") + "(from/emailAddress/address) eq'" + currentItem + "'"

So now you’ll have queryString that looks like…

(from/emailAddress/address) eq 'someone@somewhere.com' or (from/emailAddress/address) eq 'another@somewhere.com'

etc.

Put queryString variable into the query property of the get mail activity.

@automated

It would be the same listmails as the unfiltered one

Or you can assign to same variable as well

Cheers

Hello @Anil_G @postwick

my issue is solved now, I have used the below if condition in for-each loop.
NOT arr_Email.Contains(currentItem.SenderEmailAddress)
arr_Email is array of string

Thanks for your suggestions, were really helpful to me.

1 Like

Yeah but then you’re getting ALL emails and then looping through them. It’s more efficient and faster to filter the emails you get, so you don’t have to loop through them all and use the If.

You can get just the emails you want, not all of them:

Let me try this and get back to you.
Thanks.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.