Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Save Attachments as Sharepoint Files Producing Empty Files

(0) ShareShare
ReportReport
Posted on by 163

Hey all!

 

I'm having a little trouble. I have a flow set up with two conditions to download and save attachments from a shared mailbox to a sharepoint folder.

 

Capture.PNG

Everything appears to be working...the correct email is pulled...the file is created and saved in the appropriate folder with the correct name. But it's empty...

 

Some of the attachments are PDFs, and some are CSV files. The CSV file that gets saved by the flow has a single cell with "null" in it. The PDF files do not open. Note that it is not an issue with the attachments themselves--they open fine and have data in them--when downloaded manually.

 

Any help would be appreciated!

 

Thanks.

 

 

  • EdTheTech Profile Picture
    3 on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    Thanks @stephenkln This solution fixed my issue!

  • crsf29 Profile Picture
    4 on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files
    My guy, access denied? I'm not sure why I wouldn't have access?
  • jltafoya Profile Picture
    3 on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    This worked for me.  Thanks!

  • Verified answer
    stephenkln Profile Picture
    163 on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    @Anonymous I found a solution that worked for me here: https://powerusers.microsoft.com/t5/I-Found-A-Bug/Email-as-an-attachement-contentBytes-is-null-bug/td-p/53524

     

    Under the advanced settings of the initial trigger..."When a new email arrives..."  change the following settings to "Yes"

     

    - Only with Attachments

    - Include Attachments

     

    Note you might have to recreate your flow to get this to work. Simply toggling them to "Yes" did not fix it for me. I had to rebuild the flow from scratch with them toggled "Yes", then my attachments started saving with all the content.

  • tom_riha Profile Picture
    10,127 Most Valuable Professional on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    Hello @Anonymous ,

    the error message tells you that the dynamic content you used in the base64ToBinary(...) is empty, I'd review what is used as the parameter and if it contains any value (store it into a Compose action before the base64ToBinary(...) expression and check if it's not empty).

  • Community Power Platform Member Profile Picture
    on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    I am having a simmilar problem and I tried to use your solution. but It dident help me.

    When I try your solution the flow fails and says the base64ToBinary was expecting a string but got a NULL.

     

    I am trying to save attached files from a e-mail sent to a shared email account in a sharepoint folder.

     

    PeFo_0-1611060996750.png

     

    PeFo_1-1611061079438.png

     

    In the Function "Vedhæftede filer" is: triggerOutputs()?['body/attachments']

    PeFo_2-1611061303346.png

    In Filnavn is used: items('Anvend_på_hver')?['name']

    In Filindhold is used: items('Anvend_på_hver')?['contentBytes']

     

    The flow runs fine and the files is saved to sharepoint. but the files saved is just max 4 byte large.

    even if the originally PDF file is 190 bytes and You cant open the file.

     

     

     

     

  • Verified answer
    tom_riha Profile Picture
    10,127 Most Valuable Professional on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    Hello @stephenkln ,

    I think the simplest solution in such cases is to store the dynamic content into a 'Compose' action and then use the output from the 'Compose' in the expression.

    image.png

  • stephenkln Profile Picture
    163 on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    @tom_riha thanks for the suggestion! I cannot get that to work. [Attachments Content] is not a dynamic content option for the expression. Any other ideas or am I not doing it right?

  • tom_riha Profile Picture
    10,127 Most Valuable Professional on at
    Re: Save Attachments as Sharepoint Files Producing Empty Files

    Hello @stephenkln ,

    try to convert the 'Attachments Content' to binary using the base64ToBinary(...) expression. The attachments from an email seem to have a different encoding than expected by SharePoint.

    base64ToBinary([Attachments Content])

    image.png

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1