I would like to filter emails such that only the emails with a subject containing a specified string is pulled through.
What would be the best way for me to do this?
Thus far I have tried to download the last 10 unread emails and then filter it in a for each where I was trying to make a list that only includes mails that have subjects which contain the string that I am looking for.
The problem here is that I could not figure out how to initialize a list of MailMessages for the Add to Collection activity. Does anyone know how to do this as an alternate method to filtering the mails?
For this
if we are using GET OUTLOOK MAIL ACTIVITY then we can directly set the filter in FILTER PROPERTY itself like this “[Subject] = ‘your string’”
of "@SQL=urn:schemas:httpmail:subject like ‘%your string%’ "
and for this
to add the mail variable to a list create a list variable of this type System.Collections.Generic.List(System.Net.Mail.MailMessage)
with default value as New List(of System.Net.Mail.MailMessage) in the variable panel named list_Mailmessages
in add to collections activity mention this variable in Collections property and in item property mention the mailmessage variable and in type argument choose as System.Net.Mail.MailMessage
However, I need to pull subjects that contain a string. There could be other words in the subject but if the subject has the string that I am looking for in it I want it saved.
So, if the Subject is “Message for UiPath bot”. And we only want emails with a subject containing “UiPath”.
At the moment in a for loop I have an if statement with the condition mail.Subject.ToLower.Contains(“uipath”) and just add the mail to a List of mailmessages.
Is there a way for me to do this in the filter of the get outlook mail message instead of doing it afterwards in a for each?