web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Save Attachments as Sh...
Power Automate
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.

 

 

Categories:
  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    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

     

  • stephenkln Profile Picture
    163 on at

    @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?

  • Verified answer
    tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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.

     

     

     

     

  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    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).

  • Verified answer
    stephenkln Profile Picture
    163 on at

    @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.

  • jltafoya Profile Picture
    3 on at

    This worked for me.  Thanks!

  • crsf29 Profile Picture
    4 on at
    My guy, access denied? I'm not sure why I wouldn't have access?
  • EdTheTech Profile Picture
    3 on at

    Thanks @stephenkln This solution fixed my issue!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 245 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#3
Valantis Profile Picture

Valantis 136 Super User 2026 Season 2

Last 30 days Overall leaderboard