cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
eyeana
Level: Powered On

Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi,

 

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:
flownzcdquestion.JPG 

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?

 

Kind Regards,

Iyana

 

9 REPLIES 9
Dual Super User
Dual Super User

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Teja_Veleti
Level: Powered On

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

@eyeana hello.

 

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.

Community Support Team
Community Support Team

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @eyeana,

 

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!

Best Regards,
Community Support Team _ Lin Tu

eyeana
Level: Powered On

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

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.

flow1.PNG

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?

 
 
 
eyeana
Level: Powered On

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

Hi @Teja_Veleti,

 

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.

flow2.PNG

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?

eyeana
Level: Powered On

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

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:flow1.PNG

 

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?

Dual Super User
Dual Super User

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

You have to initialize the variable outside the loop and then use a Set Variable or Append to Variable action inside the loop.

screenshot.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
eyeana
Level: Powered On

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

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?

Highlighted
Dual Super User
Dual Super User

Re: Create flow that deletes files in document library and sends email which mentions the files which have been deleted

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,267)