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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create folder by sende...
Power Automate
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 👍

Categories:
  • Verified answer
    Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    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

  • datalearner Profile Picture
    71 on at

    Thank you @Expiscornovus  for the reply

    I will try it and let you know the result

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 119

Last 30 days Overall leaderboard