Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Rz5JSpz+Tutpjp2V2BNRH1
Power Automate - Building Flows
Answered

Getting file content from Sharepoint and attaching to email

Like (0) ShareShare
ReportReport
Posted on 3 Mar 2023 21:34:31 by 15

Hi

 

I'm new to PowerAutomate and have tried multiple different 'dynamic content' expressions but cannot get this to work. I just want to attach a file from a sharepoint folder to an email, as soon as a new file is created in the folder. I have managed to get file information correctly into a Sharepoint List at the beginning of the flow but having trouble with the email attachment as I can get it to send an email but with a blank attachment that cannot be opened and has no file extension. The 'Attachment Content' field if i just add 'file content' as screenshot below comes up with an error message and automatically adds in 'Body'.  With 'Body' included it just send the blank file with no file extension. 

 

CeriRobbo_0-1677878658944.png

CeriRobbo_1-1677878943519.pngCeriRobbo_2-1677879039606.pngCeriRobbo_3-1677879090344.png

Thanks in advance, it is driving me crazy. 

  • Sean_Perry Profile Picture
    11 on 15 Jan 2024 at 16:37:01
    Re: Getting file content from Sharepoint and attaching to email

    After a huge amount of searching I found this response. 
    As below,  once I changed 'Body' in Attachment Content to 'File Content' it worked.
    Surprising that this was so difficult, but thanks for providing a solution to something that has been driving me crazy. 

  • MRYM290 Profile Picture
    19 on 23 Jun 2023 at 05:17:23
    Re: Getting file content from Sharepoint and attaching to email

    Hi!

    I had the same issue and your post helped me to fix it!

    thank you 🙂

  • CeriRobbo Profile Picture
    15 on 05 Mar 2023 at 19:23:18
    Re: Getting file content from Sharepoint and attaching to email

    Thanks @ekarim2020. I've done that along with adding my list tracker and it all seems like it's working great. Thanks again 🙂 

  • Ellis Karim Profile Picture
    10,936 Super User 2025 Season 1 on 04 Mar 2023 at 11:06:12
    Re: Getting file content from Sharepoint and attaching to email

    Hi @CeriRobbo ,

     

    Now that the flow is working you can use a Trigger Condition to further refine the flow to. We can use a Trigger Condition to run the flow only when a file was created (i.e. do not run the flow if a folder was created):

     

    Snag_90a88c0.png

     

    Select the Menu option (1):

    Snag_23815cc5.png

     

    Select Settings:

    Snag_2381a3e0.png

    Click add, then add the trigger condition:

    Snag_2381f173.png

     

    The flow should only trigger if the item that was just created is NOT a folder. Enter the expression as shown below:

    Snag_90eb412.png

    The expression for the trigger condition is:

    @not(triggerOutputs()?['body/{IsFolder}'])


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

     

  • CeriRobbo Profile Picture
    15 on 04 Mar 2023 at 07:50:58
    Re: Getting file content from Sharepoint and attaching to email

    I have just changed 'Body' in Attachment Content to 'File Content' and it works!!! First time I have received the file expected on email 🙂 

     

    Now I just need to work out how to fit populating some info into my list into the flow so I can keep a tracker of all the files being sent but hopefully will be able to manage this as that was working on my previous flow. 

     

    Many thanks Ellis!  

  • CeriRobbo Profile Picture
    15 on 04 Mar 2023 at 07:44:35
    Re: Getting file content from Sharepoint and attaching to email

    CeriRobbo_3-1677915723393.png

    CeriRobbo_4-1677915813976.pngCeriRobbo_5-1677915855644.png

     

     

  • CeriRobbo Profile Picture
    15 on 04 Mar 2023 at 07:39:58
    Re: Getting file content from Sharepoint and attaching to email

    CeriRobbo_0-1677915366571.pngCeriRobbo_1-1677915482743.pngCeriRobbo_2-1677915576677.png

     

  • Ellis Karim Profile Picture
    10,936 Super User 2025 Season 1 on 03 Mar 2023 at 23:49:10
    Re: Getting file content from Sharepoint and attaching to email

    Please share your flow including the runtime output of the flow for the Get File Content action. 

     

    This is the runtime from my Demo flow:

     

    Snag_6a5a093.png


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

  • CeriRobbo Profile Picture
    15 on 03 Mar 2023 at 23:39:10
    Re: Getting file content from Sharepoint and attaching to email

    Thanks for your suggestion.

     

    I've just tried that and it doesn't seem to like the 'attachment content' just being 'body' and gives the following error: 

    CeriRobbo_1-1677886613195.png

     

    Any thoughts as to why that may happen? 

     

    Many thanks 🙂 

  • Verified answer
    Ellis Karim Profile Picture
    10,936 Super User 2025 Season 1 on 03 Mar 2023 at 22:51:55
    Re: Getting file content from Sharepoint and attaching to email

    Hi @CeriRobbo ,

     

    Here is a flow that might work for you:

     

    Snag_6661aeb.png

    We want only email files when a file is created so we need to ignore if a folder was created in the document library:

    Snag_666a921.png

     

    Next get the file content and email the file to the recipient:

     

    Snag_6702eb1.png

    Snag_6708721.png

    Hope this helps.

     


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

     

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,776 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard