Filters

Hello Forum,

I need to filter outlooks email according to two criterias:

  1. if subject has a string type “AAA”, “BBB”, “CCC” etc.
    2.- if the email attachments has a string name : “AAA”, “BBB”,“CCC”, etc.

My problem is : should it be better to use (if, if-else, or Switch) to filter ? considering that each email have to be verified in two places (the subject area or the name attachement in just one passage of the algorithme)

Here i show you what i developped until now, any suggestion would be very appreciated…

note: you will see that the first If condition is set to verify email attachments (Excel type).
Then, i am expecting to use and Else-Iif nested where a want to set condition for subjects string . at this point i dont know how to set all the types of string i need to verify … and then the other problem is how to follow to the next step that is: to check if attachment’s name comply with string types…

Why don’t you use a single IF condition with an AND inside? You can check both subject and attachment names at the same time

'[Subject] = "AAAA"|"BBBB"|"CCCC"
Subject = "AAAA" or "BBBB" or "CCCC"
 

Trying using the Above expression. Use AND or OR logic for this problem.

Hello @Marco_Ber and thanks for messaging,
in fact, i have a long list (types of string) to verify not only in the subject area or the name attachment. Therefore, i had in mind two options (it is how i see and maybe i am not in the correct path to solution)

  1. first option: i use if in each type of string, but it would make a very long nested algorithme. However it would work correctly with both filter subject area or name attachments …
    2.-second option: Use a switch , but i dont know if it would work because i have two types of cases (subject verification and name attachement) … at this point i am new here and i dont know how to use it and if it is possible…

any idea or photo example would be very appreciated… thanks

But I mean, what would be the issue with using a bunch of AND in your IF condition? Nesting a lot of IF and having one IF with AND is practically the same (in this case)

Variable:
arrMatchers | String Array = {“AAA”,“BBB”, … “ZZZ”}

Following statment will retrun true, when 1 or more matcher strings are in the subject

arrMatchers.Any(Function (x) mail.Subject.Contains(x))

As you can see, we can keep it very short. Similar we can setup also the attachment check.

As a variation we can fillter also the arrMachers on present tokens and unsing the filter result for checking if the present token is matching the attachment name

1 Like

Thanks @ppr, i will process your feedback i will come back to you . :handshake:

also take the benefit of quick checking and prototyping by using the immediate panel:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum