I have set up a recurrence flow that deletes files uploaded in a SharePoint document library every night. However, I am finding it difficult to enable the flow to send email which lists the files (file name) which has been deleted. Below is my current configuration:
In my attempts, for each individual files deleted it sends an email. However, I would like all the files which have been deleted to be listed in one email. Is this possible?
Initialize either a string variable or an array before the loop to delete the files. Then add the file names to the variable. That way you'll have a list of deleted files when you want to create the email.
You should use LIST FOLDER action. That will bring in the files at once and you can email the same list. instead of using variables.
If this helps you, kindly accept as solution and give a kudos so that others can get to the solution easily.
Has your problem been solved?
If your problem has been solved, You could go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!
Community Support Team _ Lin Tu
Hi @Pstork1 ,
I have tried out your solution, however i had the following warning - The variable action 'Initialize_variable' of type InitializeVariable cannot be nested in an action of type 'Apply to each'. This warning appeared when I selected Name in the Value field.
On a general note, as soon as I select Name or Display Name when initializing variable or creating an email body, Flow would always display the Apply to each container. As a result, it would send me separate emails for each files that exist within the SharePoint list. What I want to achieve is create an email which lists all the deleted files / files within the list, instead of having an email sent for individual files. Is this possible?
I have tried the solution which you had mentioned i.e. using List Order function. However, it still didnt achieve what I had wanted to achieve. Whenever I select Name or DisplayName, the 'Apply to each' container would appear, which sends me individual emails for each files on the list.
What I would like to achieve is send an email which lists down all the files within the list which will then be deleted or vice versa. Is this possible?
Hi @Pstork1 ,
I have implemented your solution, however, it still didnt achieve what I wanted to achieve. It displayed me the warning as in the picture beside:
As a general note, whenever I select displayName or Name when initialising variable or when creating the automated email, the apply to each container would always appear, which leads the flow to send me separate emails for each of the files present within the list. What I wanted to achieve is I would like to send an automated email which lists all the files or all the files within the lists which have been deleted. Is this possible?
You have to initialize the variable outside the loop and then use a Set Variable or Append to Variable action inside the loop.
Hi @Pstork1 ,
Thank you for your help! I am now able to list the file names in one email. Is there a way to separate the file names with a comma, when jotting them down in the email?
if you look closely at the screenshot I posted you will see a semicolon after the dynamic content that appends each name to the variable. Just change that to a comma and you'll get a comma after each name. You will of course get one extra one at the end that you'll need to trim off after you exit the loop to be perfect.
Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.
Look out for new contribution recognition badges coming SOON!
We've updated and improved the layout and uploading format of the Power Automate Cookbook!
Fill out a quick form to claim your user group badge now!
The top training and networking event across the globe for Microsoft Business Applications