Do something if ForEach activity returns nothing

Hello,

I have a “For each Email” activity in a “Use Desktop Outlook App” scope.
The “For each” activity has a filter to check for certain emails (“From certain email address” and with “Subject equals certain subject”).

If there are no emails with these particular properties, the flow exits (or rather, skips) the For Each Activity.

How might I use this in an If condition? Because I would like to have something like “if no emails found with these properties, do something”.

Thank you.

@Dragos_Nae,

You should be able to do it this way.

Get Outlook Messages can work outside of Outlook App Scope.

Sample Code:
Outlook Demo.xaml (11.3 KB)

Thanks,
Ashok :slight_smile:

I’ve actually solved it in a different way: I assigned a “FoundEmail” variable as False before the “For each email” activity and I mark the variable as True if it finds an email inside the ForEach. If not, the variable remains False.