web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter email by receiv...
Power Automate
Unanswered

Filter email by receive date using power automate desktop

(2) ShareShare
ReportReport
Posted on by 108

Hi All,

 

I get an email every day with the same subject, 1 email a day. I've put them all in one folder. i created a custom form in the beginning of my flows that requires to input a received date. So now i want to retrieve the email by the specific received date and i want to save the email attachment to my local drive.


Anyone can help me with this? many thanks

I have the same question (0)
  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Do you have premium license? If so I suggest using Office 365 Outlooks Get emails (V3) -action for this since regular Outlook retrieve email messages -action does not have date filter.

    Get emails (V3) has Search Query field where you can filter the date received like so:

    eetuRobo_0-1720497673474.png

    To have the date dynamic use Convert text to datetime -action to convert the date from the form to yyyy-MM-dd format.

    eetuRobo_0-1720500380558.png


    Then use that variable to Get emails (V3) search query

    eetuRobo_1-1720497912579.png


    Also specify the subject in the advanced

    eetuRobo_2-1720498092470.png


    And since you said you get just one of those emails a day that has that subject then it should only receive one item.

    Then use Get Attachemnt (V2) to get that specific attachment. You get the message id and attachment id from the GetEmailsV3Response

    eetuRobo_3-1720498599893.png

    Message Id: %GetEmailsV3Response['value'][0].id%
    Attachment Id: %GetEmailsV3Response['value'][0]['attachments'][0].id%

    Then you can use Convert Base64 to file -action to download the attachment file to the folder you want

    eetuRobo_5-1720499370065.png

    Base64 encoded text: %GetEmailsV3Response['value'][0]['attachments'][0].contentBytes%

    Flow overall:

    eetuRobo_4-1720499242665.png



    If you don't have premium license or for some other reason need to use other than Office 365 Outlook -actions you have to loop all the messages to find correct date. So first you get all the emails with same subject and loop them all to find the one with the date from the form. That will be very time consuming though.


    Check this blog post for the idea:
    https://www.samurai-emblem.com/2023/08/03/power-automate-desktop-mail-filter-date-from-to/ 

  • Sayan Profile Picture
    818 Super User 2025 Season 2 on at

    Hey @rrrradfafwgvafv 

    In Power Automate Desktop there is no certain type of Action which can directly filter the Email.

     

    Please follow the below steps -

     

    Sayan_0-1720469463377.png

     

    Also Copy and Paste this code just made some necessary changes It will work

     

    SET Date TO $'''08-07-2024'''
    Outlook.Launch Instance=> OutlookInstance
    Outlook.RetrieveEmailMessages.RetrieveEmailsAndSaveAttachments Instance: OutlookInstance Account: $'''sayan.patra@xyz.com''' MailFolder: $'''Inbox''' EmailsToRetrieve: Outlook.RetrieveMessagesMode.All MarkAsRead: True ReadBodyAsHtml: False SubjectContains: $'''Documents''' SaveAttachmentsInto: $'''C:\\Users\\SayanPatra\\Documents\\IPRU''' Messages=> RetrievedEmails
    LOOP FOREACH CurrentItem IN RetrievedEmails
    Text.ConvertDateTimeToText.FromDateTime DateTime: CurrentItem.Date StandardFormat: Text.WellKnownDateTimeFormat.ShortDate Result=> FormattedDateTime
    IF FormattedDateTime = Date THEN
    IF IsNotEmpty(CurrentItem.Attachments) THEN
    LOOP FOREACH Attachment IN CurrentItem.Attachments
    File.Move Files: Attachment Destination: $'''C:\\Users\\SayanPatra\\Downloads''' IfFileExists: File.IfExists.DoNothing MovedFiles=> MovedFiles
    END
    END
    END
    END

     

    After that if the solution not work. Please share your workflow.

    ------------------------------------------------------------------------------------------------------------------------------

    If my suggestion helped you, please give it a Thumbs up and Mark it as a Solution so that it can benefit others in the community.

    Sayan Patra

    RPA Developer

    Follow me on LinkedIn 

     

  • mathiaskjeldsen Profile Picture
    224 on at

    Hey @rrrradfafwgvafv 

     

    You need to set a variable with the date and use that as reference in the flow afterwards. You do that by using Get Current Date and Time and converting it afterwards to the format needed. Then when you get to the email filter, you use that variable as input to which email to open. I explained the first part of it here, if you are confused on how to get it to work.

     

    Automate Excel File Opening with Data-Driven Flows in Power Automate Desktop

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard