Applying multiple filters in email automation

I have a question about applying multiple subject filters in the Get Outlook Mail Message activity or within a For Each Email loop.

My requirement is as follows:

I need to apply 10 filters based on subject lines, with all the filter criteria stored in a database.
The bot should read emails from the inbox, compare their subject lines against the entries in the database, and proceed with processing if the subject matches the ones stored in the database.

To begin, retrieve the subject lines from the relevant column in your database and store the results in a DataTable using the appropriate database query. Next, convert the specific column into an array. In an assign activity, you can use this expression:

subjectArray = dataTable.AsEnumerable().Select(Function(row) row.Field(Of String)(“subjectColumn”).ToString).ToArray()

Here, subjectArray is an array of strings that holds the subject lines.

Once the emails are fetched using the Get Outlook Mail Message activity, store them in a variable called emailMessages. Then, iterate over the emailMessages using a For Each loop, ensuring the type argument is set to System.Mail.Mailmessage.

Inside the loop, use an If statement with the following condition:

subjectArray.Contains(email.Subject)

If the subject matches, the process will continue in the “Then” block; otherwise, it will follow the “Else” block.

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