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 / Creating a flow that d...
Power Automate
Unanswered

Creating a flow that dynamically creates folder structure in Sharepoint based on subject parameters and saves emails and attachments to said folder

(0) ShareShare
ReportReport
Posted on by 8

Hi all!

For a bit of context, I've been trying to create a flow in Power Automate that not only saves emails and their attachments to Sharepoint but also stores said email in a folder based on a particular client. I've managed to so far get the email/attachment saving completed but how would I enable the creation of a folder automatically in Sharepoint based on a client name and date specified in the subject line? I would like to see something like the following:

 

Email Subject Line

New Trade - Client: <Client Name>; Date: <YYYY-MM-DD>

 

Flow Explanation

1. First, create a folder labeled after the Client Name parameter in the subject line provided above

JohnL1212_1-1697747293432.png

2. Second, create a subfolder within the Client Name folder that contains the Date parameter in the subject line

JohnL1212_2-1697747715788.png

3. Finally, save all emails and their associated attachments in the date folder for a client

I've managed to get #3 complete with the flow below but am struggling to find out how to do steps 1 and 2. Would anyone have any experience with this sort of flow? Ideally, I would love to automate this archiving process.

JohnL1212_0-1697751769934.png

Categories:
I have the same question (0)
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,315 Super User 2025 Season 2 on at

    Hi @JohnL1212 

     

    I am making assumptions based on your format of the Subject.

     

    Step 1. The Email triggers

    Step 2. You validate its the right email, however you do it, you need to do this before you do anything else

    Step 3. Parse the client name from the Subject

     

    So pretend I have this as the subject

    New Trade - Client: new Client; Date: 2019-01-01

    I will create 2 Initialize Variables and set them to type string, 

    1. I named this ClientName and to get the client name value for it use the below expression.

    a) Which will first split by the ; which you have.

    b) Then it will trim off spaces on ends

    c) Then it will spit again based on the string New Trade - Client:

    d) And then again trim spaces.

    e) This gives you the Name

    trim(split(split(variables('Subject'), ';')[0], ':')[1])

     

    Step 4. Parse the date string from the Subject

    Tto get the Date I named this one DateValue

    trim(split(split(variables('Subject'), ';')[1], ':')[1])

     

    As you can see I now have those values in my variables ClientName and DateValue

     

    Step 5. Create the top folder (assuming it doesnt exist, which you should check first but up to you)

    -Add a Create new Folder (SharePoint action)

    --add your site address

    --add your list or library path

    --use the ClientName variable for your first folder

     

    Step 6. Create the date folder (assuming it doesnt already exist, which you should check)

    -Add another Create new Folder (SharePoint action)

    --add your site address

    --add your list or library path

    --now use this as an expression

    concat(variables('ClientName'), '/', variables('DateValue'))

     

    And now you have them created and you can save your file. Just remember when you go to save files, you must use the proper ID from the Create new Folders, to identify the folder to go to since it didnt exist before.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • JohnL1212 Profile Picture
    8 on at

    Thank you @FLMike! I will give it a try when I have a chance in a bit and keep you posted. Much appreciated.

  • JohnL1212 Profile Picture
    8 on at

    Thank you @FLMike  - this worked beautifully. Now to add conditions to check if those folders exist... If I have questions about conditions, I will post another thread.

  • JohnL1212 Profile Picture
    8 on at

    Hi @FLMike , for initializing the Client Name and Date Value variables, is there a way to tweak the expression to also take into account Replies and Forwards? I realize now that Replies and Forwards also use colons (RE: and FW:) and I would like to similarly capture those emails as well since there could be additional details pertaining to those trade deals. Should I tweak the expression or alter the subject to use different characters to differentiate Client Name and Dates?

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