Get email based upon dynamic filter criteria

MailSubjectFilterCriteria = “Test;Test1;Test2;Test3”

Means I have get all emails for which subject contains “Test” or “Test1” or “Test2” or “Test3”

This is I can do using below

Mail.Subject.Contains(“Test”) Or Mail.Subject.Contains(“Test1”) Or Mail.Subject.Contains(“Test2”) Or Mail.Subject.Contains(“Test3”)

but challenge is in feature I can have filter criteria like below

MailSubjectFilterCriteria = “Test;Test1;Test2;Test3;Test4” ( Test4 is extra here or something can be removed)

I have write dynamic filter criteria which can handle any kind of MailSubjectFilterCriteria

Please help

#UipathHelp

example
string MailSubjectFilterCriteria = "Test;Test1;Test2;Test3;Test4"

  1. assign
    filterString (string variable) = String.Join(" OR ", MailSubjectFilterCriteria.Split(";"c).AsEnumerable().Select(function(x) "[Subject] = '"+x+"'"))

now filterString will equal [Subject] = 'Test' OR [Subject] = 'Test1' OR [Subject] = 'Test2' OR [Subject] = 'Test3' OR [Subject] = 'Test4'

  1. in get outlook message activity, set filter = filterString

workflow
image

Thanks a lot for your solution however I have to use Subject.Contains method function because Test or Test1 (MailSubjectFilterCriteria ) are just part of subject line, not exact subject line.
Can you please help

change filterString to this

filterString = String.Join(" OR ", MailSubjectFilterCriteria.Split(";"c).AsEnumerable().Select(function(x) "urn:schemas:httpmail:subject like '%"+x+"%'"))

filterString = "@SQL="+filterString

image

1 Like

Thanks a lot for your help

1 Like

Sorry to bother you again
This filter is not working for O365 :frowning:

yes its supposed to work for OUTLOOK not O365…

try this

filterString = 
String.Join(" OR ", MailSubjectFilterCriteria.Split(";"c).AsEnumerable().Select(Function(x) "contains(subject, '" + x + "')"))

Thanks buddy. You are a Rockstar

1 Like

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