cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamB2
Helper I
Helper I

Uploading Excel email attachments to SharePoint library

I have built a Flow that automatically uploads Excel email attachements to a SharePoint library. The Flow runs successfully, and appears to be okay, however I am unable to open the files from SharePoint (both web version and desktop version). Does anyone have any idea? Screenshots below. Thanks!

 

Flow:

 

flow error.png

 

SharePoint (looks okay):

 

sp doc.png

 

Web Error Message:

 

Error web.png

 

Desktop Error Message:

 

excel error.png

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

Hi @SamB2 ,

 

You can try the following:

Snag_4b17647.png

 

You can copy-and-paste the following into the compose action: 

 

{
  "$content-type": @{items('Apply_to_each')?['contentType']},
  "$content": @{items('Apply_to_each')?['contentBytes']}
}

 

 


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

View solution in original post

11 REPLIES 11
ekarim2020
Super User
Super User

Hi @SamB2 ,

 

Please see:  How to save PDF email attachments to OneDrive for Business using Power Automate – Ellis Karim's Blog which you can easily change to handle Excel files:

 

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

Hi @EK - thanks for your response however this looks to be exactly the same as my Flow already (see my first screenshot above). Just for completeness I have tried changing Attachment Name ends with (instead of contains). The Flow appears to work okay and looks good in SharePoint, it is just when I open up the file I then get the error message.

ekarim2020
Super User
Super User

Hi @SamB2 ,

 

Can you check that you can open the file attachments within Outlook? We want to make sure that the file is valid and isn't corrupt.

 

What file size is reported in SharePoint after the file has been saved? 

Snag_3f17b1f.png

Try deleting the create file action, then re-add the create file action.


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

 

Yes I can open the attachments okay in Outlook, and can also manually upload the files to SharePoint which also open okay, it is just when the Flow runs I get the error. There are some files that do work but there are also some that don't and I can't see anything different with these.  

ekarim2020
Super User
Super User

(1) What is the file size that is reported for the files that you can't open.

Snag_3f72ab0.png

(2) Can you preview the file within the browser. Don't open the file using the Excel desktop app but preview within the browser:

 

ekarim2020_0-1663161888545.png

 

Ellis

 

1. An example of one that doesn't open has a file size of 23.7KB, whereas I have ones that do work with file sizes of 26.3KB. 

 

2. I am unable to preview the affacted files in trhe browser (I get the same error message as my 3rd screenshot in original post). 

ekarim2020
Super User
Super User

I can't see an issue with the flow itself.

 

1. Try deleting the create file action, then re-add the create file action. Test

2. Try deleting the trigger action, then re-add the trigger action. Test.

3. Or save a new copy of the flow or Create a new flow.  Test. Remember to turn off the old flow.

 

Occasionally flows or actions are known to get corrupted. It's more time efficient to delete and the re-add actions than trying to debug flows.

 

Ellis

SamB2
Helper I
Helper I

I have just tried recreating the Flow from scratch and am still getting the error on some files. I have also asked a colleague to try and they are getting the same too.

ekarim2020
Super User
Super User

Hi @SamB2 ,

 

You can try the following:

Snag_4b17647.png

 

You can copy-and-paste the following into the compose action: 

 

{
  "$content-type": @{items('Apply_to_each')?['contentType']},
  "$content": @{items('Apply_to_each')?['contentBytes']}
}

 

 


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

@ekarim2020  thanks for this - using that compose action appears to be working! Further down in the Flow, it uploads the file to another location which I left as the orginal Attachment Content (dynamic content) and that one still wasn't working, whereas it uploaded in the first location fine. I note you said for testing purposes only, can this not be used as a permanent solution? 

Hi @SamB2 ,

 

Yes, the solution can be used permanently.  In the compose action we are manually specifying the "File Content" properties, whereas in the Create File action, the properties are set using the dynamic Attachments Content. Both the compose action and the dynamic Attachments Content should be exactly the same.

 

I suspect that the "$content-type" property may be missing during the Create File action and this is what may be causing your problem. This seems to be a bug. The issues occurs sometimes but we don't know what the root cause of the problem is.

 

When I remove the "$content-type" property from the compose action I get the same error:

ekarim2020_0-1663178074868.png

 

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

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,651)