Skip to main content

Notifications

Community site session details
Power Automate - General Discussion
Answered

Flow - Delete emails older than 7 days

Like (0) ShareShare
ReportReport
Posted on 11 Apr 2019 08:13:35 by 5

Hi There,

I'm trying to create a Flow to delete messages older than 7 days in Folder, but I have a problem.

 

This is my Flow:

flow01.JPG

 

When in the field Search Querry I add "received:yesterday", the flow is working, and the messages are successfully processed, but when I add  "received:last week" not working.

 

This is the output:

 

flow04.JPG

 

This is the output with "received:last week" in the query:

 

flow03.JPG

 

I tried to add the search query in double quotes, but in this case, the flow fails.

 

in the email folder, there is a lot of messages from the last 10 days (02 to 11 of April)

 

One more question - into the TOP field in "Get emails" step, I'm trying to put more than 25 items, but in this case, the Flow fails again. Is there a limitation for this?

 

Thanks in advance for any idea,

Krasimir

 

 

  • Tobias_S Profile Picture
    93 on 13 Mar 2023 at 11:11:40
    Re: Flow - Delete emails older than 7 days

    Thanks for your support and the provided link 🙂

  • VictorIvanidze Profile Picture
    12,214 on 11 Mar 2023 at 14:40:16
    Re: Flow - Delete emails older than 7 days

    See https://ivasoft.com/archiveemailsflow.shtml

  • Tobias_S Profile Picture
    93 on 18 Feb 2022 at 09:18:34
    Re: Flow - Delete emails older than 7 days

    I am trying to build the same automation but cannot see the "body" as it is shown in your flow. There is only "v2" available as well.

     

    Mailarchiving.PNG

  • HodgsonIM Profile Picture
    30 on 17 Dec 2019 at 16:36:44
    Re: Flow - Delete emails older than 7 days

    @nick4924 ,

     

    The problem is the 25 item limit. It can't get to the stuff old enough to delete because it is only looking at the first 25 emails. This limit is keeping me from using this flow option to complete the same task.

  • nick4924 Profile Picture
    18 on 11 Nov 2019 at 10:48:36
    Re: Flow - Delete emails older than 7 days

    Hello, 

     

    I made the same flow as is solution here and it doesn’t work.

    Can you please check it and tell me why?..
    Snímek obrazovky 2019-11-11 v 11.20.58.png

    Spoiler (Highlight to read)
    formatDateTime(item()['DateTimeReceived'],'yyyy-MM-dd')
    formatDateTime(item()['DateTimeReceived'],'yyyy-MM-dd')
    Spoiler (Highlight to read)
    addDays(utcNow(),-90,'yyyy-MM-dd')
    addDays(utcNow(),-90,'yyyy-MM-dd')

    I need delete mails older than 3 months, that’s why 90 in second formula.

    Unfortunately flow posts this:

    Snímek obrazovky 2019-11-11 v 11.25.49.png 

     

    Test of flow is always the same - expression result = false, so anything won’t be deleted.

    Snímek obrazovky 2019-11-11 v 11.27.38.png

     

    And proof that in the inbox are mails older than 3 months..

    Snímek obrazovky 2019-11-11 v 11.42.23.png

     

    I will be very grateful for every comment.

    Thank you,

    D.

     

  • Krasimir Profile Picture
    5 on 12 Apr 2019 at 09:55:54
    Re: Flow - Delete emails older than 7 days

    Thanks. The solution works perfectly!

     

  • Verified answer
    v-bacao-msft Profile Picture
    on 11 Apr 2019 at 10:36:38
    Re: Flow - Delete emails older than 7 days

    Hi @Krasimir ,

     

    Please consider directly comparing the current time and the time the message was received, and then delete the eligible email.

    Expression reference:

    formatDateTime(item()['DateTimeReceived'],'yyyy-MM-dd')
    addDays(utcNow(),-7,'yyyy-MM-dd')

    Image reference:50.PNG

    Please take a try.

     

    Best Regards,

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard