@zxky18
Please follow the below screenshot and code. You can save your attachment by default during retrieve email messages from outlook and it will be saved on "C:\User\Documents" folder".

Flow Screenshot:

Please find the below code[Copy and paste the below code into you PAD designer and understand how it functioning):
Outlook.Launch Instance=> OutlookInstance
# By default all email will be saved in the config folder(C:\Users\Documents)
Outlook.RetrieveEmailMessages.RetrieveEmailsAndSaveAttachments Instance: OutlookInstance Account: $'''Deenu@microsoft.com''' MailFolder: $'''Inbox''' EmailsToRetrieve: Outlook.RetrieveMessagesMode.Unread MarkAsRead: True ReadBodyAsHtml: False SubjectContains: $'''Product''' SaveAttachmentsInto: $'''C:\\Users\\Documents''' Messages=> RetrievedEmails
LOOP FOREACH CurrentEmail IN RetrievedEmails
IF (StartsWith(CurrentEmail.Subject, 'Hello', False) OR Contains(CurrentEmail.Subject, 'Hello Message', False)) = $'''True''' THEN
Display.ShowMessageDialog.ShowMessage Title: $'''test''' Message: $'''Email with filtered subject''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
ELSE
# If you email attachment doesn't contain your keyword then delete your attachments
File.Delete Files: CurrentAttachment
END
LOOP FOREACH CurrentAttachment IN CurrentEmail.Attachments
# If Attachment is .xlsx file then rename it with timestamp
IF Contains(CurrentAttachment.Extension, $'''xlsx''', False) THEN
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''ddMMyyyy''' Result=> FormattedDateTime
File.RenameFiles.Rename Files: CurrentAttachment NewName: $'''%CurrentAttachment.NameWithoutExtension%_%FormattedDateTime%%CurrentAttachment.Extension%''' KeepExtension: True IfFileExists: File.IfExists.Overwrite RenamedFiles=> RenamedFiles
END
END
END
New to power automate desktop? Not sure how to copy/paste the code. Please refer the below gif.

Thanks,
Deenuji Loganathan 👩💻
Automation Evangelist 🤖
Follow me on LinkedIn 👥
-------------------------------------------------------------------------------------------------------------
If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏