cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EllrickB
Frequent Visitor

Loop through subfolders in a shared mailbox

Hello All,

I have a shared mailbox that is receiving emails from many different domains using a catch-all and forwarding rule on the domain registrar level. Next, the rule on OWA moves the email to a corresponding subfolder based on the recipient (domain)name.

To make sure there is no issue with forwarding on the domain level, once a week, I send a test email to all domains/subfolders and then manually check each of the 50 subfolders.

Now, I know I can create a Flow for each subfolder to check if the email has been received from aaa@xyz.com and then do something.
Is there a way to check all subfolders in a shared mailbox if the email hasn't been received, I would like to use single Flow for this task.

I would have to loop through each subfolder and check if there is email from aaa@xyz.com if not then send a notificaiton.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
lbendlin
Impactful Individual
Impactful Individual

That is good. In that case you can create an array with the folder paths, and then loop over that

lbendlin_0-1664626138606.png

In the Get Emails step you can specify your conditions.  After the call you can check if it returned at least one email (in which case you skip to the next folder) or not (in which case you would send the notification - or collect the folder name so you can send a combined notification after all folders are checked).

View solution in original post

10 REPLIES 10
lbendlin
Impactful Individual
Impactful Individual

Is your folder list static (ie could it be provided in an array and iterated over) or do you want a flow that automatically traverses all subfolders?

It’s static, thanks!

lbendlin
Impactful Individual
Impactful Individual

That is good. In that case you can create an array with the folder paths, and then loop over that

lbendlin_0-1664626138606.png

In the Get Emails step you can specify your conditions.  After the call you can check if it returned at least one email (in which case you skip to the next folder) or not (in which case you would send the notification - or collect the folder name so you can send a combined notification after all folders are checked).

EllrickB
Frequent Visitor

Thanks @lbendlin I’m curious now, how would deal with this if the folders are dynamic and new ones are added or removed.

lbendlin
Impactful Individual
Impactful Individual

I only know how to do that using Outlook VBA, Powershell, or a standalone C# app.   I don't think there are any options in Power Automate to do that - maybe via Graph API?

EllrickB
Frequent Visitor

I can't figure out how to create a condition which checks if email exists.

If I check for the email body in empty subfolder condition fails with: 

Unexpected error. Request to Azure Resource Manager failed with error: '{"error":{"code":"ActionRepetitionNotFound","message":"The specified repetition '000001-000000' of workflow action 'Condition' is not found."}}'.

 If the email is found in subfolder then condition is True. Any idea @lbendlin ?

 

cond.png

lbendlin
Impactful Individual
Impactful Individual

Configure two parallel actions. One gets triggered on previous step success, the other on failure.

VictorIvanidze
Community Champion
Community Champion

In "Get emails" set top to 1.  As the output of "Get emails" is an array, check its length.

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

EllrickB
Frequent Visitor

Here is a full flow if anyone can benefit from it.

 

1.png

 

2.png

 

3.png

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,884)