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 / How to create a workfl...
Power Automate
Unanswered

How to create a workflow to receive email notifications when a document is due to expire in a Document Library

(0) ShareShare
ReportReport
Posted on by 33

I would like to create a workflow to receive email notifications 7 days prior expiry date of documents in a Document Library. I don't know if it is possible since I only found on Lists, but I need it on Document Library.

 

Any help please?

 

Thanks,

Yanika

Categories:
  • grantjenkins Profile Picture
    11,063 Moderator on at

    Did you want a summary email to go out daily containing a list of documents that are going to expire in exactly 7 days? And if so, do you have a specific Date column on your library that contains the expire date for each file?

  • yanika22 Profile Picture
    33 on at

    I want to receive an email when documents are due to expire. I have a column named Expiry Date so when the date is due, it will send an email. The documents are in a Document Library not in a List, and I don't know if it is possible. Can you help out please?

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Hopefully this is what you're looking for.

     

    For this example, I'm using the following Document Library. There are currently two files that will expire in 7 days.

    grantjenkins_0-1678971689793.png

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_1-1678971727101.png

     

    Recurrence is set to run daily so the flow runs once a day. You can set actual time you want the flow to run.

    grantjenkins_2-1678971774482.png

     

    Get files uses the following expression for the Filter Query so it only returns files where the Expiry Date is 7 days from today.

    //Note that the internal name of my Expiry Date is ExpiryDate
    
    ExpiryDate eq '@{addDays(utcNow(), 7, 'yyyy-MM-dd')}'

    grantjenkins_3-1678971924984.png

     

    Condition uses the following expression in the filter which checks if any files are returned. We will only send the email if at least one file is expiring in 7 days. If at least one file is returned, we will go into the Yes branch.

    length(outputs('Get_files_(properties_only)')?['body/value'])

    grantjenkins_4-1678971949393.png

     

    Create HTML table uses the output from Get files and maps the fields we want to display in our HTML table.

    grantjenkins_5-1678972020838.png

     

    Style HTML table is a Compose action (I just renamed it) that contains some CSS to style the HTML table so it looks nicer in the email.

    <style>
     table {
     border-collapse: collapse;
     }
     table td,
     table th {
     border: 1px solid #ddd;
     padding: 6px 20px;
     text-align: left;
     }
     table th {
     background-color: #1C6EA4;
     color: white;
     }
    </style>

    grantjenkins_6-1678972092029.png

     

    Send an email will send an email to whoever you put in the To field. It uses the output from Style HTML table and Create HTML table.

    grantjenkins_7-1678972140546.png

     

    If we ran the flow now, we would get the following email.

    grantjenkins_8-1678972183342.png

  • yanika22 Profile Picture
    33 on at

    Thanks for your reply. Regarding the Filter Query, the internal name of the column, you mean how it is shown when you click on the column? So, I have to write it down as Expiry_x_0020_Date please?

    yanika22_0-1679389975219.png

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Correct - it needs to whatever the internal name of the column is.

  • yanika22 Profile Picture
    33 on at

    So on a test site it worked, but when I created it on the proper site, it told me that it has succeeded but it skipped sending the email....!! The condition retrurned False, but as you can see, the expiry date is set for the 28th March and I should receive it today (7 days before). The workflow is working, but for some reason it did not return the email

    yanika22_0-1679407862672.pngyanika22_1-1679407887595.png

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    It might be due to the time zone set for your site. Can you alter the flow, so it adds either 6 days or 8 days in the Filter Query and see if that picks up the document then?

     

    addDays(utcNow(), 6, 'yyyy-MM-dd')
    
    //OR
    
    addDays(utcNow(), 8, 'yyyy-MM-dd')

     

  • yanika22 Profile Picture
    33 on at

    The time zone is correct. I have created another document library on the same site, created the workflow and it worked. It is something to do with that particular document library.

    All I can say is that the site has been migrated from SharePoint on prem to SharePoint Online and the document library has been created on prem and then migrated. I cannot think of anything else. 

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 132

Last 30 days Overall leaderboard