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 / Saving Email to File e...
Power Automate
Unanswered

Saving Email to File explorer folder

(1) ShareShare
ReportReport
Posted on by 61

Hello, 

 

I need help with saving an email along with attachments to a file explorer folder. 

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Sh99 

     

    You can follow the below approach:

    Deenuji_2-1719938253030.png

    Code:

     

    Outlook.Launch Instance=> OutlookInstance
    Outlook.RetrieveEmailMessages.RetrieveEmailsAndSaveAttachments Instance: OutlookInstance Account: $'''Deenu@microsoft.com''' MailFolder: $'''Inbox''' EmailsToRetrieve: Outlook.RetrieveMessagesMode.All MarkAsRead: False ReadBodyAsHtml: False SubjectContains: $'''test''' SaveAttachmentsInto: $'''C:\\Boot''' Messages=> RetrievedEmails
    LOOP FOREACH CurrentItem IN RetrievedEmails
     Outlook.SaveOutlookEmailMessages.SaveEmailsAs Instance: OutlookInstance Account: $'''Deenu@microsoft.com''' EmailsToSave: CurrentItem SaveFormat: Outlook.MessageType.OutlookMessageFormatUnicode SaveEmailsAs: $'''Anytext_%CurrentItem.Subject%''' SaveEmailsTo: $'''C:\\Boot''' MessagesFiles=> StoredMessagesFiles
    END

     

     

    How to copy/paste the above code into your power automate desktop?

    Deenuji_1-1719938107359.gif

     

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @Sh99 !

     

    You can follow this organized approach. Here is my flow:

    NathanAlvares24_1-1719938683513.png

     

    Aim of this flow:

    Initially I specified my main folder path, wherein there will be folders created based on subject name (just an example). Then I am saving all the attachments onto the main folder. Later then it will save the email message as .msg in the new created subject name folder. Thereafter, I move those attachments to the said folder. Resulting in an organized approach of saving .msg files and the attachments.

     

    My emails:

    NathanAlvares24_0-1719938657692.png

     

    Output:

    Before:

    NathanAlvares24_2-1719938734647.png

     

    After:

    NathanAlvares24_3-1719938750332.png

    NathanAlvares24_4-1719938757859.png

    NathanAlvares24_5-1719938765040.png

    NathanAlvares24_6-1719938773060.png

     

    Code (just copy paste this into your flow):

     

    SET MainFolderPath TO $'''C:\\Users\\Username\\Desktop\\EmailMessages'''
    Outlook.Launch Instance=> OutlookInstance
    Outlook.RetrieveEmailMessages.RetrieveEmailsAndSaveAttachments Instance: OutlookInstance Account: $'''Username@hotmail.com''' MailFolder: $'''Inbox''' EmailsToRetrieve: Outlook.RetrieveMessagesMode.Unread MarkAsRead: False ReadBodyAsHtml: False FromContains: $'''nathanlalvares@hotmail.com''' SaveAttachmentsInto: MainFolderPath Messages=> RetrievedEmails
    LOOP FOREACH RetrievedEmail IN RetrievedEmails
     Folder.Create FolderPath: MainFolderPath FolderName: RetrievedEmail.Subject Folder=> NewFolder
     Outlook.SaveOutlookEmailMessages.SaveEmailsAs Instance: OutlookInstance Account: $'''Username@hotmail.com''' EmailsToSave: RetrievedEmail SaveFormat: Outlook.MessageType.OutlookMessageFormatUnicode SaveEmailsAs: RetrievedEmail.Subject SaveEmailsTo: NewFolder MessagesFiles=> StoredMessagesFiles
     File.Move Files: RetrievedEmail.Attachments Destination: NewFolder IfFileExists: File.IfExists.DoNothing MovedFiles=> MovedFiles
    END
    Outlook.Close Instance: OutlookInstance

     

     

    I hope this helps.

  • Sh99 Profile Picture
    61 on at

    Thanks this was really helpful, only the email message is not getting saved properly

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @Sh99 !

     

    Could you specify what was the issue? It saves as a .msg format. Do you want to save it as a different format? If yes, you can choose to save in html, text, etc. just by changing the type from the dropdown mentioned in the "Save outlook email messages" action.

     

    Please do let us know.

  • Sh99 Profile Picture
    61 on at

    In your image when you save the email to the folder its coming as an email icon. Its not showing up the same for me. I am saving as the format as you .msg format. 

  • Sh99 Profile Picture
    61 on at

    Kindly check the image. 

    Email Msg.png
  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @Sh99 !

     

    Its because I chose Outlook as default to open all my .msg files. First right click on that .msg file and follow the next:

    NathanAlvares24_0-1719949333772.png

    Then click 'Always'

     

    You have to make sure you have Old Outlook App on your machine for it to work though.

     

    I hope this helps.

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Sh99 

     

    It appears you haven't set a default application for .msg files, which is why it's displayed in that manner. Right-click on the .msg file, select 'Properties', then click 'Change'. Choose 'Outlook' and then click 'Set as default'.

    Deenuji_0-1719975014189.png

     


    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 🚀

     

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Sh99 ,

     

    Please find the solution.

    VishnuReddy1997_0-1719981517702.png

     

    Code:

    Outlook.Launch Instance=> OutlookInstance
    Outlook.RetrieveEmailMessages.RetrieveEmailsAndSaveAttachments Instance: OutlookInstance Account: $'''vishnuvardhanreddy@cacme.com''' MailFolder: $'''Inbox''' EmailsToRetrieve: Outlook.RetrieveMessagesMode.Unread MarkAsRead: True ReadBodyAsHtml: False SubjectContains: $'''HLS DU''' SaveAttachmentsInto: $'''C:\\Users\\Desktop\\Power Automate Desktop\\Practice\\Outlook\\output''' Messages=> RetrievedEmails
    LOOP FOREACH CurrentItem IN RetrievedEmails
     Outlook.SaveOutlookEmailMessages.SaveEmails Instance: OutlookInstance Account: $'''vishnuvardhanreddy@cacme.com''' EmailsToSave: CurrentItem SaveFormat: Outlook.MessageType.OutlookMessageFormatUnicode SaveEmailsTo: $'''C:\\Users\\Desktop\\Power Automate Desktop\\Practice\\Outlook\\output''' MessagesFiles=> StoredMessagesFiles
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 424

#2
11manish Profile Picture

11manish 328 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard