Skip to main content

Notifications

Power Automate - General Discussion
Answered

Power Automate - Multiple files from Onedrive to email attachment

(0) ShareShare
ReportReport
Posted on by 9

Hi, I have flows set up to save attachments from emails to a onedrive for business folder - This works OK.

 

I then have a flow set up to check the count of files in the folder and if 2 or more, attach those files to an email, send and then delete the source files. This flow runs without error however the file content being sent/received is incorrect. 

 

The input data is .txt or .csv files and contains data like:

KhrisJones_0-1632230552448.png

however the data being received over email (With the right filenames) has data like:

KhrisJones_1-1632230620008.png

My flow is set up to trigger when a file is saved, list files in folder, for each file increase the value of a Integer variable, then i initialise an array variable, then do a check on the integer variable and if greater than or equal to 2 it proceeds to this step:

KhrisJones_2-1632230777104.png

 

Then the email that is sent has the allattach variable listed in the attachements section:

KhrisJones_3-1632230818078.png

 

Ive tried searching a number of other posts/questions/guides however everything i can find is using Sharepoint instead of onedrive and the actions are subtlety different. 

 

Any help is appreciated,

 

Thanks,

Khris

 

 

 

  • KhrisJones Profile Picture
    KhrisJones 9 on at
    Re: Power Automate - Multiple files from Onedrive to email attachment

    Thanks DamoBird365 - Absolutely right in that i need to use the File Content, i was following guides for Sharepoint and they say about using the array and the name + Body but its so obvious now we have mentioned it. 

     

    It works now using the file content but i will digest what you have said and hopefully give that a try to see the outcome if it would be a more efficient solution.

     

    Thanks again,

  • KhrisJones Profile Picture
    KhrisJones 9 on at
    Re: Power Automate - Multiple files from Onedrive to email attachment

    Thanks Eric-Cheng - Im not entirely sure why i had it set up as body, I was following a how to guide but as you have written, its quite obvious now to think it should be the File Content from their. Probably due to the guides i was looking at referencing SharePoint and adding it in this way (Name and then Body).

     

    I have changed this and it ran successfully first time, thank you for highlighting that so quickly!

  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Power Automate - Multiple files from Onedrive to email attachment

    @KhrisJones 

     

    You need to check the dynamic value that you have used for file content.  It is returning a JSON array of the body - you specifically want file content from the get file content action.

     

    Here is an alternative solution for you to explore too:

     

    DamoBird365_0-1632231837971.png

     

    Expressions are highlighted in comments.  You can use length() to get the length or number of objects (i.e. files) returned in an array.  Then get the file content in an apply to each and create a compose for each attachment.

     

    DamoBird365_1-1632231879124.png

     

    Outside of the Apply to each, call the compose actions into an array using outputs() and place that into your email.

     

    You will not need to use variables and hopefully have a more efficient solution.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

     

  • Verified answer
    eric-cheng Profile Picture
    eric-cheng 5,171 on at
    Re: Power Automate - Multiple files from Onedrive to email attachment

    Hi @KhrisJones ,

     

    In your append to array action, can you please check you are referencing the correct value for ContentBytes?  I believe it should be File Content from Get File Content 2.

    --------------------------------------------------------------------------
    If I have answered your question, please mark my post as a solution
    If you have found my response helpful, please give it a thumbs up

    Connect on LinkedIn

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,495

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,822

Leaderboard