How to Filter IMAP Emails based on Subject

Hi All,
I want to filter Emails which i get from IMAP Activity based on Subject.
However, i don’t want to Loop all the mails and then put a If condition as (if item.Subject.contains(“EMail Subject”))

Is there any other way to filter with list of mail messages directly?

1 Like


For Get IMAP Mail Message Activity, we don’t have any option. But you can use Get Outlook MailMessage Activity to do this and it has direct option like Filter. By using this, we can filter our mails based on subject, body and sender etc…

If you want to work with Outlook application it should be installed in our machine and also it should be in online.

unfortunately i don’t want to use Get Outlook mailmessage Activity for this.
As IMAP activity doesnt have filter option, are there any .net or vba methods to filter?

as we use .select method for datatable, does List of mailmessage also any anything as such?


We will use select method after scraping the data to filter dataTable. But as you said you want to do it in Activity itself and unfortunately we don’t have that option for Get IMAP Mail Message Activity.

No Lakshman i didn’t want to do it in activity. It’s ok for me if we use Assign Activity and assign the filtered list of mail messages to new Variable also.
It’s just that i want to skip looping and putting a if condition in it thats it.


Try below steps:

  1. Get IMAP Mail Message activity will give output as list of mail messages and say ‘mailMessages’.

  2. Then use below expression to apply filter based on subject of the mails.

mailMessages = mailMessages.AsEnumerable().Where(Function(x) x.Subject.ToString.Equals(“requiredSubject”)).ToList


Thanks, this works fine


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