Introduction

One of the neat features that is available in on-premises SharePoint but not in Office 365 is the email-enabled list. This feature allows a list to have a special email address that can receive mail from users. By default, the emails will then be stored in that list, but custom processing of the emails can occur using an event receiver. A common example of that is using an event receiver to strip out attachments from incoming emails and store them in a document library.

This blog post will implement a work-around for this feature using the new Azure App Service. More information on the service itself can be found in the links included in the Reference section at the end of this blog post.

Azure Marketplace

To begin, you will need to open the new Azure Portal (currently in preview status.) Click the “New” button in the lower left corner of the portal. Choose “Developer Services” from the list in the “Create” blade. Use the search box to find each of the resources required by this blog post: Logic App, SharePoint Online Connector, and Office365 Connector.

Add a Logic App

Click the “Create” button in the bottom of the Logic App blade. Fill in the name of your Logic App in the Name textbox. Choose the subscription you would like to use for this. Choose the datacenter location for this. For now, do not touch the Triggers and Actions. Select or create an App Service Plan. You cannot create an empty App Service Plan, so this is the only to make a new one if desired. The pricing tier is important when it comes to how often you would like to check for new email. The Basic tier only allows polling intervals of hourly or more. When finished, click the “Select” button in the bottom of the Choose Your Pricing Tier blade followed by the “Create” button in the bottom of the Create Logic App blade.

Add a SharePoint Online Connector

Click the “Create” button in the bottom of the SharePoint Online Connector blade. Many of the options are the same as the Logic App. The one main difference is Package Settings. These settings must be configured properly for your SharePoint Online Connector to work. Enter URL of the site that contains the list you wish to email-enable in the Site URL textbox. For example: http://starcrossed.sharepoint.com. Enter the site-relative URL of the list you wish to email-enable in the Document Library/List Relative URLs textbox. For example: Shared Documents. When finished, click the “OK” button in the bottom of the Package Settings blade followed by the “Create” button in the bottom of the SharePoint Online Connector blade.

Add an Office365 Connector

Click the “Create” button in the bottom of the Office365 Connector blade. Many of the options are the same as the Logic App and SharePoint Online Connector. When finished, click the “Create” button in the bottom of the Office365 Connector blade

Design the Logic App

Click the Triggers and Actions tile in the EmailEnabledList blade. The first thing you will want to add is a trigger. For this blog post, we will be triggering on receiving a new email in Office365. Click the SharePoint Online Connector from the API Apps in This Resource Group list on the right side of the Triggers and Actions blade. You will need to authorize the Office365 Connector by clicking the “Authorize” button. This will pop-up a login page where you will need to enter the Office365 credentials for the mailbox that you would like monitor. Once authenticated, you will be asked to choose one of the available triggers. Currently, the Office365 connector only has one trigger: New Email. Click on “New Email.” You are now presented with some options for how often you would like to poll the mailbox as well as mail properties to match on when creating a list item from a new email. For demo purposes, I chose to poll every 5 minutes, and I left all of the properties blank. This means it will create a list item for every received email. Just like the Office365 Connector, you must also authorize the SharePoint Online Connector by clicking the “Authorize” button. List items will be saved using the credentials used for authorization. Once authorized, you must choose an action to perform when the Logic App is triggered. For this blog post, we will use the Upload To action. This will let us create a document based on the email received and store it in the document library that we put in our settings for the SharePoint Online Connector, Shared Documents. For demo purposes, we will just save the body of the email as the content of the document. This can be done by clicking the elipses (…) next to the Content textbox. From the drop-down, choose “New Email Body”. Leave Content Transfer Encoding as “None.” Click the elipses next to the Document Relative URI textbox. From the drop-down, choose “New Email Subject” to set the filename to the subject of the received email. Leave Force Overwrite as “false.” Click the elipses at the bottom to open more options. Click the elipses next to the Title textbox. From the drop-down, choose “New Email Subject” to set the Title column for the document to the subject of the received email. Leave ExtUserInviteTest blank. When finished, click the checkmark button at the bottom.

Test the Logic App

Send an email to the account you used to authorize the Office365 Connector.

Depending on your chosen interval, you should see the results show up. Click the link under Runs Today in the EmailEnabledList blade. Find the run corresponding to the latest date and time within your chosen interval and click on it. As you can see from the list view in SharePoint Online, the document was added. The filename, Logic App Test, corresponds to the subject line that I used in my email. By opening the document in Notepad, you can see that the body of the email was saved as the content of the document.

Conclusion

As you can see from this basic example, the ability to process incoming Office 365 emails with SharePoint online is easy to setup using Azure App Service. More robust solutions are definitely possible by expanding on the skeleton Logic App provided in this blog post. I am excited about this new tool for creating solutions for Office 365 and SharePoint, and I look forward to learning more advanced techniques for using it.

If you have any questions about this blog or would like to discuss Azure App Service in more detail, I can usually be found in the SharePoint Community chat room during the week. You can also reach me on Twitter.

References

(22569)