Category Archives: Microsoft Flow

Copy new Email and Details From Outlook 365 to SharePoint Online Document Library, Microsoft Flow: Mail Enable Office 365 SharePoint Online

Parent Post – Requirements and InformationCopy new Email and Details From Outlook 365 to SharePoint Online Document Library, Microsoft Flow and Logic Apps: Mail Enable Office 365 SharePoint Online

Related Post – Logic AppsCopy new Email and Details From Outlook 365 to SharePoint Online Document Library, Logic Apps: Mail Enable Office 365 SharePoint Online

How to create a Microsoft Flow to pass an email from Outlook 365 to a SharePoint Online Document Library

  1. Go to your SharePoint Online site
  2. Create a document library to receive the emails
  3. In your document library, create a flow (in the modern UI click Flow -> Create a Flow, click "See more templates", click "create a flow from blank"). If you are using classic view, you can simply go to https://us.flow.microsoft.com/manage, login and under My Flows click "Create from blank"
  4. In your new flow, the below should be displayed. Click "Office 365 Outlook"
  5. Click "Office 365 Outlook – When a new email arrives" trigger
  6. You will need to choose which email address you want the trigger to watch, mine has automatically used the email address I am signed in as. To change this click "Add new connection" and then make sure is it ticked under "My connections". MAKE SURE you set "Include Attachments" to yes, or the attachments part will error
  7. I have left all of the other options default, but you can add other filters for the trigger to look for such as a subject keyword
  8. Click "New Step" -> "Add an Action"
  9. Type in "Content Conversion" and click on "Content Converstion – Html to text" – NOTE: we are adding this step as generally emails are in HTML and this shows as HTML markup when you add the Body of the email into a .txt file in SharePoint. Converting to plain text means we can add just the text and not HTML markup from the Body
  10. In the "Content" field, enter "Body" by double clicking the value "Body" under "When a new email arrives -> Body" as seen below
  11. Click "New Step" -> "Add an Action"
  12. Click on SharePoint
  13. Click "SharePoint – Create file"
  14. Enter the Site Address for your site collection or subsite, then select the Folder Path as your document library
  15. NOTE: as with Outlook, SharePoint also has "My connections" on the "…" menu, make sure you use the user you want to add the items to SharePoint. I have used the user I am logged in as
  16. For the File Name we will enter the From field "_" and the utcNow() function. This will make the file name easy to identify by who it is from but also unique based on the utc date and time. You will find all of the email fields under "Dynamic content" and functions such as utcNow() under "Expression". Scroll down to "Date and time" section, double click on utcNow() which will enter it into the expression field, then click OK
  17. Ensure you type in ".txt" at the end of the file name. The type of file is not decided for you and .docx does not work (throws an error that it can't open the document)
  18. For the "File Content" field you can enter a mixture of dynamic and static content. I have entered a number of the email fields due to the fact that I can't assign these to metadata. Note that "Dynamic content" pop up box groups available information by the action it comes from, e.g. below we have "Html to text" and "When a new email arrives". You'll also notice there is a "See more" button which will show more hidden fields. You can also just search dynamic content and it will filter the list so you can quickly find values
  19. Below you can see what I have chosen for the File Content. Notice that I have used "The plan text content." from the "Html to text" group instead of the Body field
  20. Now we need to add any attachments from the email. Click "New Step" -> "Add an Action"
  21. Click "SharePoint"
  22. Click "SharePoint – Create File" action
  23. Enter the site URL and the document library. Under file name, click "Name (Attachment name)"
  24. This will convert your create file action into an "Apply to each" action as it will need to loop through each attachment
  25. Let's make the "File Name" more useful, add the From field, "_ATT_" (to signify it's an attachment), utcNow() and Name field. When the item is added to the document library it should now look similar to the main email and group better, especially if you set your default view to sort by created date descending and then by File Name, you will be able to tell quickly that the email has attachments associated with it
  26. For the "File Content" field, enter "Content (Attachment content)"
  27. Your final attachment loop should look like the above
  28. Update your flow, you're now ready to test it!
  29. Create an email and add a couple of attachments. Send this to the email address you setup for the email trigger to watch
  30. It will take a few moments for the email to get picked up. You can view the run history and other details on your flows main screen, you should be taken here once you update your Flow and click "Done"
  31. Once it has successfully run, I can see my email plus two attachments in my document library
  32. If we open and view the txt file

Copy new Email and Details From Outlook 365 to SharePoint Online Document Library, Microsoft Flow and Logic Apps: Mail Enable Office 365 SharePoint Online

Related Post – Logic AppsCopy new Email and Details From Outlook 365 to SharePoint Online Document Library, Logic Apps: Mail Enable Office 365 SharePoint Online

Related Post – Microsoft FlowCopy new Email and Details From Outlook 365 to SharePoint Online Document Library, Microsoft Flow: Mail Enable Office 365 SharePoint Online

 

I've been working with a customer to figure out a way to email enable lists or libraries in Office 365/SharePoint Online. After deciding that a third party tool wasn't ideal, we looked at Logic Apps and Microsoft Flow. I found a few articles but they were out of date and not fully functional.

I'm writing this article to help fill the gaps until more funtionality is available for the SharePoint connectors and also to help clear up some of the things that took a bit of meddling to figure out. 

Here are the requirements and some comments on current restrictions. Restrictions apply to connectors for both Logic apps and Microsoft Flow as of 01/08/2017. If you are looking at this in September or beyond have a search around to see what Microsoft have implemented since this post. 


Requirement 1

Recieve an email to an email address. Once email received, it is picked up and processed into a document library

Comments

The reason we ended up using a document library instead of a list is currently there is no way to add attachments to a list item (this should come eventually), which means we can't add the BODY content as an attachment or the attachments in the email as attachments.

Ideally we wanted to grab the whole email, attachments and all and add the .msg file to the document library. This isn't possible (but also on the radar from Microsoft).

To work around this we will be creating a .txt file for all of the email details (from, subject, date received, has attachments?, body) and additional files for each attachment.

Requirement 2

Add metadata to the item for email fields

Comments

Sadly this isn't currently possible but it IS on the radar for development. You can only add metadata to a list item and not a document library. Adding metadata to list items also isn't ideal due to the fact you are restricted to 255 characters for string fields, not enough for the BODY content. 

For now the workaround is to pass all of these fields into the document we create in the document library.

I'll cover how to achieve this in both logic apps and flow, though both have pretty similar steps. NOTE: Flow is built ontop of Logic Apps, they are fairly similar but FLOW is accesable from SharePoint and more power user focused, where Logic Apps is more developer focused. 

Instructions for building mail enabled libraries in Office 365

I have split Logic Apps and Microsoft Flow into two seperate posts to reduce size

Logic AppsCopy new Email and Details From Outlook 365 to SharePoint Online Document Library, Logic Apps: Mail Enable Office 365 SharePoint Online

Microsoft FlowCopy new Email and Details From Outlook 365 to SharePoint Online Document Library, Microsoft Flow: Mail Enable Office 365 SharePoint Online

Other notes

I noticed over night that random spam from Microsoft processes made it's way into my document library. You may want to trigger the email received action based on a specific folder and route emails that match criteria to the folder.