Showing results for 
Search instead for 
Did you mean: 
Level: Power Up

Save email attachments to Sharepoint that are only PDF, DOC* and XLS* files

I am busy trying to write a Flow that saves all my email attachments to a folder in Sharepoint. The problem is that I only want PDF, XLS* and DOC* files to avoid all the image files in signatures etc. The problem I am having is that my conditions are correctly picking up the word .pdf in the attachment name but then the next step just adds all the attachments to the designated folder. The bottom screenshots show the test result on the first attachment, an image file and the last, a PDF.


Below is screenshots of my settings. Any help would be much appreciated.


Level: Powered On

Re: Save email attachments to Sharepoint that are only PDF, DOC* and XLS* files



I did a quick test and built the same Flow as you, but for testing I saved the files to my OneDrive for Business instead of SharePoint.  This worked fine, and out of the 6 attachments in my email (Word, PDF and images) it only saved the Word and PDF to my OneDrive folder.  So you are saying that all of the images are getting saved there too?  Do your Attachment Name show the Apply to Each like mine in the screenshot below?  Maybe its picking it up from the original trigger and from the foreach, so its grabbing all instead of the filtered condition.  That is what it sounds like anyway.  



Level: Power Up

Re: Save email attachments to Sharepoint that are only PDF, DOC* and XLS* files

Thanks for having a go. Yep, I also have 'Apply_to_Each' 


Below is the code for the Create File. I think the problem is it is not applying the Condition at the right time which is above my paygrade. No doubt it is one line of code so any assistance would be appreciated.


'Create file' (code view)
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['shared_sharepointonline']['connectionId']"
        "method": "post",
        "body": "@base64ToBinary(items('Apply_to_each')?['ContentBytes'])",
        "path": "/datasets/@{encodeURIComponent(encodeURIComponent(''))}/files",
        "queries": {
            "folderPath": "/Shared Documents/Scans",
            "name": "@items('Apply_to_each')?['Name']",
            "queryParametersSingleEncoded": true
        "authentication": "@parameters('$authentication')"
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "CreateFile"

Helpful resources


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,900)