web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Save email attachments...
Power Automate
Unanswered

Save email attachments based on attachment name

(0) ShareShare
ReportReport
Posted on by 10

I am looking to create a flow that will save email attachments to specific folders based on their file names. I would like to set up an excel file or sharepoint list that will contain the information needed including the filename and the filepath where the file should be saved so that as i add additional filenames/folders, i dont have to modify the flow. 

So, if the attachment filename contains X0881 it would move it to a specific folder C:\data\881\

and if the filename contains X0904 it would move it to a specific folder C:\data\904\

and so on. 

 

Any thoughts?

Categories:
I have the same question (0)
  • Brad_Groux Profile Picture
    4,556 on at

    You can do this fairly simply, although I highly recommend avoiding an Excel file due to the many Excel Connector restrictions. A Visual Explanation of Flow Logical Expressions can get you started down the right path.

    Basically you need to create a logical expression to check the attachment names of received emails, and if and when the match is met, it dynamically creates the matching subdirectory, and saves the file with a matching name.

    This Modify Dynamic Content Before Use in Flow thread has a very similar request. 

     

  • nedwards87 Profile Picture
    10 on at

    I have the logical expression down so that Flow can identify the email attachements based on the name, however, i am stuck on how to get flow to dynamically save the file to different folders based on theattachements filename. My initial though was to create a sharepoint list that contains the matching filenamename in one column and the folderpath where the file should be save in another column. 

  • v-yamao-msft Profile Picture
    on at

    Hi @nedwards87 ,

     

    You may consider using Switch case in your flow.

     

    If the file name contains X0881, then it goes to the action to create the file under folder  C:\data\881\.

    If the file name contains X0904, then it goes to the action to create the file under folder C:\data\904\.

     

    More details about Switch case for your reference:

    https://flow.microsoft.com/en-us/blog/search-by-service/

     

    Best regards,

    Mabel

     

  • nedwards87 Profile Picture
    10 on at

    This is how I currently have it configured but it is not ideal as we have more than 80 different files names right now and the case is limited to 27. The case method then requires cases within a case to get to 80. In the next few months we will be increasing to over 100 different filenames that the flow will need to process. This method is also extremely slow and when an email comes in with 8 attachments, it takes Flow about 10 seconds per attachment to process. 

  • Verified answer
    v-yamao-msft Profile Picture
    on at

    Hi @nedwards87 ,

     

    If the files name are always in the same format, please try if the following way will work for you.

     

    In this scenario, the file name will be the format likes “X0881Document”, I then get the key number 881 from the name and use it as the folder name. If a folder of name 881 already exists, the file will be created automatically, else, create the folder first, then create the file.

     

    The function used in the Compose action:

     

    substring(items('Apply_to_each')?['Name'],2,3)

     

     

     

    An image for your reference:

    1.PNG

     

    Further, you could also try with what you’ve mentioned in your original post,, using an Excel or SharePoint list that contains the information needed including the filename, filepath. Then adding a condition to check if the attachment name contains the filename, if yes, create the file to the corresponding filepath.

     

    Best regards,

    Mabel

     

  • nedwards87 Profile Picture
    10 on at

    Thanks for the reply. I have adopted your first solution for the time being. I do have a question, how would you reference the sharepoint list and pull the correspoding column for the filename?

  • Community Power Platform Member Profile Picture
    on at

    Thank you for your response, it does help me solve part of a problem that I have right now. I thought about creating a new post, but this problem is very similar to the one I have.

     

    I want to generate a flow that: 1. Gets attachments from specific email addresses; 2. Saves the attachments with a specific number given in the subject of the email. 

     

    So overall I know how to create the flow based on the "Save Office 365 email attachments to OneDrive for Business" template. However, I do not know how to save the attachments given a specific parameter on the subject line.

     

    Thank you in advance for your help!

  • Sumanth2205 Profile Picture
    6 on at

    Hi All,

     

    Help me in creating a flow. Below is my requirement.

    1. When a new mail arrives in Outlook with attachments

    2. Create a new folder in One Drive with the attachment name and save it. 

     

    I tried it but getting errors.

    I am stuck pls help.

     

    Sumanth2205_0-1637930894671.png

     

  • Katie12341 Profile Picture
    28 on at

    Hi, 

     

    I am looking to do something similar but slightly different. We have a series of employee folders in a sharepoint folder called Employee Files. The employee files are named lastname_firstname_employeenumber e.g. obrien_katie_002594 - the employee number is always six digits. I would like to automatically file certain documents that are sent to us e.g. training certificates. I can arrange for the certificates to be named employeenumber_certificate. I'd like the flow to trigger on the file landing in the overall employee files folder and then be able to find the right folder to move to based on matching the employee number. Is this possible? 

     

    I am completely new to power-automate so have only managed to do a couple of basic flows. 

     

    Thanks in advance, Katie

  • Sedjie Profile Picture
    3 on at

    @Katie12341 I'm also looking to do similar! hopefully we can both find the answer and make our lives easier!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard