You can use the Get IMAP Mail messages activity to read all the messages. Then using the IMAP output mail variable, use a for each activity to loop through it. Within the for each loop, use a IF activity to check for your condition.
Just like explained in here…
Hope it helps