Showing results for 
Search instead for 
Did you mean: 
New Member

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.


Helper I
Helper I

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.  



New Member

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

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,302)