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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 467 members 4,535 guests
Please welcome our newest community members: