Skip to main content

Notifications

Community site session details

Community site session details

Session Id : LFMbNeJ7vbUB4BWrBtTp+V
Power Automate - Building Flows
Unanswered

Extracting Email attachments when Subject contains specific Value.

Like (0) ShareShare
ReportReport
Posted on 22 Mar 2023 07:42:59 by 5

FBKB_0-1679470710269.png

The outcome of the condition is always false. 

 

Essentially this is a Microsoft form that all the outcomes of the form go to a excel table. the form number is used to communicate across business suppliers, and is always within the subject of an email chain for one department of the company. 

i am trying to extract attachments from emails containing the specific form number and place them into a folder that is named the form number. (This already works - i have a folder automatic creation working). 

 

Help Please?

  • FBKB Profile Picture
    5 on 23 Mar 2023 at 07:51:22
    Re: Extracting Email attachments when Subject contains specific Value.

    Thanks for this reponse.

     

    I have about 500 form numbers, so 5000 is plenty. this is great....however, i think it will create a folder for every single form number every time an email has arrived, because its not in a loop? this means that it takes over 15 minutes to run. 

     

     

  • grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on 23 Mar 2023 at 01:53:01
    Re: Extracting Email attachments when Subject contains specific Value.

    How many rows do you currently have in your Excel Table? List rows present in a table will only return up to 256 rows by default. If you have more than 256 rows, you would need to change it to allow more. I've rebuilt the flow how I would achieve this, so it avoids the looping and condition within each iteration.

     

    For this example, I'm using the following Excel Table. It just contains a list of Form numbers.

    grantjenkins_0-1679529443582.png

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_1-1679529479462.png

     

    When a new email arrives would be setup as below. This would be your Shared mailbox trigger.

    grantjenkins_2-1679533640384.png

     

    List rows present in a table would retrieve the Excel Table data. If you have more than 256 rows, then you can set the Top Count to a max of 5000 so it will return up to 5000 items. If you had more than 5000 items, then let me know and we can add Pagination and a Threshold to get more if required.

    grantjenkins_3-1679533755234.png

     

    Filter array will filter out the data, so it only returns items where the Subject contains the Form Number. If no matches, then we would get nothing returned. However, if at least one match, then we would get data returned.

    grantjenkins_4-1679533981438.png

     

    If there is a match, then we expect there to be 1 result. Condition checks the length of the Filter array to determine if any matches. If there are, then we go into the Yes branch and continue. We would use the following expression.

     

    length(body('Filter_array'))

     

    grantjenkins_5-1679534154861.png

     

    Apply to each will iterate over each of the attachments from the email and use Create file to create a file for each one using the Attachments Content. For Folder Path I would use the following expression to build up the path including the Folder with the name of the current Form Number that was matched. If the folder doesn't already exist, it will be created automatically.

     

    //Folder Path
    
    //You would replace /Shared Documents/Assorted Files/ with your base path
    
    concat('/Shared Documents/Assorted Files/', first(body('Filter_array'))?['Form Number'])

     

    grantjenkins_6-1679534526553.png

     

    If we sent an email where the Subject contained 'Form 1' and had three attachments, we would get the following output.

    grantjenkins_7-1679534598916.png

  • FBKB Profile Picture
    5 on 22 Mar 2023 at 11:08:25
    Re: Extracting Email attachments when Subject contains specific Value.

    Anyone?

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started