Re: Saving email attachments (.msg) with flow
At the risk of muddying the water......
If you are trying to get at the attachments inside of an email message, if the attachment is an Outlook item (e.g. calendar event, mail message) or it's an attached email for other mail clients (e.g. GMail), the Get Email (v2) action and the Export Email (v2) action will NOT contain the contents of those attachments in the output of those actions. But there are two ways to workaround this.
1) Use @Jay-Encodian 's guidance above to pipe the Export Email (v2) action's output into an .EML file (e.g. SharePoint Create File action) and then users can open that .EML file and get at the attachments (emails, images, DOCX, etc.).
2) Use the Microsoft Graph API's Get Message and Get Attachment endpoints which return those "item attachments" in the output so you can directly manipulate them in your Flow. The Known Issues section of the Office 365 Outlook connector docs gives some instructions on how to get at the appropriate API endpoints. https://docs.microsoft.com/en-us/connectors/office365/
Here is the relevant info, but see that page for the current info:
There are two types of email attachments:
- File attachments: Any file, such as a .txt, .jpg, .zip, .pdf etc. A file attachment only has a few properties, one of which is the base-64 encoded content of the file. Latest versions of all triggers support these attachments. EML, MSG and ICS should be attached as files to be available in triggers responses.
- Item attachments: Email messages and calendar items that are attached to an email. An item attachments has a lot of properties. These attachments are not supported by the connector at the moment. To workaround this issue, you can do the following:
If you decide to go straight at the Graph API (e.g. using an Azure Function that gets invoked by your Flow), make sure you consider usage of the ?$expand=attachments parameter to get the nested message's properties included in your root call.
e.g. GET https://graph.microsoft.com/beta/users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}/attachments?$expand=attachments
P.S. Big shout out to Encodian (and Jay) for their product Flowr. At my work we use Flowr for generating PDFs from complex and dynamic templates that were far too painful to do with Word templates. We also use some of its other handy features (e.g. image resizing, QRCode generation). If you're doing anything with email messages, their attachments, images, PDFs, PDF text extraction, you owe it to yourself and your sanity to use Encodian Flowr. It's paid for itself many times over at my workplace. Now back to our regularly schedule program (i.e. PowerAutomate and its MIA features).