Check if Mail subject/body contains an item from list of strings

Hey guys,
@aksh1yadav @nadim.warsi @Palaniyappan
I am reading emails from an inbox and trying to check if subject/body contains any of the items that are present in a list of strings.
Can someone please help?
Thank you!

1 Like

If you want to search for multiple items
"@SQL=urn:schemas:httpmail:subject like '%Your text1%' or urn:schemas:httpmail:subject like '%Your text2%'"

@Manjunath_Ramappa

Try this.

        yourArrayList.Contains("Subject mail")

If it exists then it will give you output as True else False.

well, you can loop through list of strings and use if conditions to check if any items are matching with the list of strings!

Thanks for your reply.
I guess it should be other way around as Subject may contains other strings and always returns false in this case ?

Thanks for your reply.
I guess it should be other way around as Subject may contains other strings and always returns false in this case ?

@Pradeep_Shiv Thank you, but I am already looping through list of mail messages here. Also I have more than two list of strings( too many items to loop through) to check. Please suggest.

@Manjunath_Ramappa

It will give True if any of the string matches with list of strings else it will give output as False.

Hi
May I know how many list variables we have
Cheers @Manjunath_Ramappa

I am always getting False. Please check below;

List items: {“J10023”,“J10024”,“J10025”,“J10026”}

MailSubject: J10023:Excellent Opportunity, revert if interested.

Listitems.Contains(MailSubject) returns false.

1 Like

Hi set the condition like this
listvariable.ToArray().AsEnumerable().Where(Function(a) Mail.Subject.ToString.Contains(a.ToString)).Count>0

If the count is more than one then the subject has that term and it goes to THEN apart

Cheers @Manjunath_Ramappa

1 Like

Thanks for responding :slight_smile:
I have 3 list variables each containing multiple items.

1 Like

Kindly try with this condition with OR operator inbetween each list variables

Cheers @Manjunath_Ramappa

Perfect! Thank you, let me try and update. Cheers @Palaniyappan

1 Like

It works for my requirement. :slight_smile:
Is it also possible to get which of the item is matching here ? would be great if I can get it as I need to perform a few more steps based on the item matched!

yah ofcourse like this
str_value = listvariable.ToArray().AsEnumerable.Where(Function(a) Mail.Subject.ToString.Contains(a.ToString)).ToString

Cheers @Manjunath_Ramappa

Hi @Palaniyappan,
I did not quite get this. wanted to get the matching list item, if mail subject/body is matching with my 1st list item or 3rd list item.
workflow is like below;

  1. get all the 3 list items
  2. read email
  3. loop through each email. If subject/body matches with any of the list item, get the value of that item from the list. It can be from any of the list.

Thank you for all your suggestions again! :slight_smile:

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