Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Create folder by sender and date

(0) ShareShare
ReportReport
Posted on by 71

Hi Community,

For example, I received an email from abc@powerautomate.com on 6/24/2024, I am finding difficulties in making the following scenario in PA:

  1. PA should verify if I have a folder with the sender name (abc)
  2. PA shoulde verify if I have a folder with the year of the received email (2024)
  3. PA shoulde verify if I have a folder with the month of the received email (6)
  4. Then save the attachement in the month subfolder

For each sender I should have this structure within a main Folder:

Folder by sender name (abc) / Folder by year / Folder by month

 

If the folder is not found, PA should create it, and run the whole flow for the new coming emails.

 

Any suggestions? Thank you in advance.
@Expiscornovus @fchopo @StalinPonnusamy allow me adding you to this post for help 👍

  • datalearner Profile Picture
    71 on at
    Re: Create folder by sender and date

    Thank you @Expiscornovus  for the reply

    I will try it and let you know the result

  • Verified answer
    Expiscornovus Profile Picture
    32,102 Most Valuable Professional on at
    Re: Create folder by sender and date

    Hi @datalearner,

     

    You could use an expression to extract what path you need to check. That expression uses a split and first to retrieve the name from the from field. It also uses formatdatetime and concat functions to retrieve the date related folders from the receivedDateTime field. After that you can check if the folder exists and only create it if needed.

     

    Below is an example

    I have used the has failed approach, which it will because it will return a NotFound error when the folder does not exist. However, other errors could also occur. So, it is better to use a condition action and check for the NotFound error instead. This is just a simple example to demonstrate the approach.

     

    1. A Get Folder metadata using path is used. 

     

    The expression used to reconstruct the path via a concat function.

     

     

    NameOfLibrary/@{concat(first(split(triggerOutputs()?['body/from'], '@')), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'yyyy'), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'MM'))}

     

     

     

    2. A Create new folder action is added

    The configure run after setting in this action is configured to only run this action when the previous action has Failed.

     

    Expression used in Folder Path

     

     

     

    concat(first(split(triggerOutputs()?['body/from'], '@')), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'yyyy'), '/', formatdateTime(triggerOutputs()?['body/receivedDateTime'], 'MM'))

     

     

     

    createnewfolder_check.png

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1