cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CryptoFD
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.

Page1.pngPage2.png

2 REPLIES 2
dougallen
Level: Powered On

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

@CryptoFD,

 

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.  

 

Capture.JPG

CryptoFD
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('https://domain.sharepoint.com/sites/NameofSite'))}/files",
        "queries": {
            "folderPath": "/Shared Documents/Scans",
            "name": "@items('Apply_to_each')?['Name']",
            "queryParametersSingleEncoded": true
        },
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "CreateFile"
        }
    }
}

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,860)