cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EFixler
New Member

Email Notification for files added in folder and subfolders

Hi - New to Power Automate

 

I am trying to send an email notification when a file is added to a folder and any subfolders in that directory.

The files are located in OneDrive for Business

 

I can get a notification if it is placed in the main folder or if I designate a subfolder, but I can't seem to get it to work to look at all folders and subfolders in the directory to trigger the notification.

 

I am looking to have the notification indicate the file name and path.

 

Also the path has a lot of misc data preceding the actual location that is not discernable to the user.  It would be nice just to have the path only.

Thank you, 

6 REPLIES 6
ChrisPiasecki
Super User
Super User

Hi @EFixler ,

You just need to specify Include in subfolders. In the below example it will trigger when any file is created in the root or any child subfolders.

 

Cpiasecki_0-1604027702405.png

 

 

The filepath from the trigger output is base64 encoded. So to get just the filepath, you can use the following expression:

last(split(base64ToString(triggerOutputs()?['headers']['x-ms-file-path-encoded']),'root:'))

 

What this expression does is:

  • Convert the base64 path to a string
  • Does a split function by searching on the word root:, and the output is an array.
  • The last function will take the last element of the array, which will be the rest of the path string after 'root:'.

In my example, I uploaded a file called 'test.txt' at the path My Files > Subfolder > SecondLevel.
In the email, the resulting file path from the expression would be '\SubFolder\SecondLevel\test.txt'

---

Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

Thank you for the response.

 

This seems to get stuck on the first subfolder.  If you have multiple folders, and place the file in any folder below the first the notification runs and indicates a new file was added but the path directs you to the first subfolder, not the correct folder where the file was added.

Hi @EFixler,

I am having a bit of trouble visualizing what you mean. Could you post a screenshot of what you are seeing and advise what it should look like? 

EFixler
New Member

Awesome! Thanks its working now.

 

Is there any way to make the email with the path to the One Drive location?

Hi @EFixler,

I'm not quite sure I understand. The example I posted sends an email that shows the file path. Is there a different attribute you are referring to, such as the Url to the item? 

One more question to ask.  If multiple files are added, can the email notification be sent once with the list of the new files on each line? Right now it send an email for each and every file separately.

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (76,739)