Hi I new here, so I need to iterate through mail and check their subject if the subject is "Invoice I need to proceed further or else I need to throw an error after loop is completed I already created workflow but its not working when email subject is dif

please follow these steps.
1-get unread mail messages list from mail.
2-loop over mail message list.
3-put condition inside loop.
4- Condition Item.Subject.ToString.Contains(“Invoice”)
5- if the condition is true put all the process in your then block.
6- if mail not contains “Invoice” then put assign activity in else block and in assign activity put bool variable.
7- use bool variable outside if where you want to throw exception