How to filter an outlook email address using an array

How can I use the outlook filter option to exclude multiple emails?
I am using “ExcludeMail” as array

“[senderemailaddress] <> '”+in_ExcludeMail+"’"

@Julian_Claessen Can you use this in an Assign Statement and check if it Works :

msgs = msgs.Where(Function(x)ExcludeMail.Any(Function(y)x.Sender.ToString.Contains(y.ToString))).ToList

Where ExcludeMail is an Array of String that contains mail addresses, and msgs is the Output Of Get Mail Messages Activity i.e List (Of MailMessage)

Should I mention it after the for each loop or before? I keep getting a error

@Julian_Claessen I think you need to use InboxMails variable instead of msgs variable :sweat_smile: . The Order is right but make sure you use exclude variable in the expression that i have given instead of ExcludeMail

1 Like

It works but it only selects the mails mentioned in the exclude array, which need to be the opposite way around :thinking:

Exclude: {“”, “”}
InboxMail: {“”, “”, “”, “”}

Results should be mails only from : and

1 Like

@Julian_Claessen Oh Yes. I forgot you need to exclude the mails :sweat_smile: There is a NOT operator missing, try below expression :

InboxMails = InboxMails.Where(Function(x)Not(exclude.Any(Function(y)x.Sender.ToString.Contains(y.ToString)))).ToList


It works! Thanks :grinning: :ok_hand:

1 Like

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