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

Community site session details

Session Id : sOkhBg9S/LYLHiLzYyAQkK
Power Automate - Building Flows
Answered

Create folder by sender and date

Like (0) ShareShare
ReportReport
Posted on 26 Jun 2023 12:05:54 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 👍

I have the same question (0)
  • datalearner Profile Picture
    71 on 27 Jun 2023 at 11:57:48
    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,245 Most Valuable Professional on 27 Jun 2023 at 11:27:29
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 954 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 650 Moderator

#3
trice602 Profile Picture

trice602 327 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete