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

Page1.pngPage2.png

2 REPLIES 2
dougallen
Helper I
Helper I

@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

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (39,890)