Read Outlook Emails and Add Email Content in SharePoint List

This SharePoint 2013 tutorial, we will explore how to read an email in Outlook and add the content of the email body to a SharePoint List in SharePoint 2013. We can achieve this by writing a C# console application using Microsoft Exchange Web Services.

If we talk about a requirement, let’s take a part of an HR Portal in which an HR sends some information about newly joined employees to, let’s say, admin team via an E-mail. Then, the admin team stores the information of each employee in the SharePoint List manually.

We are writing a console application here where every email with Employee details will be creating an item in the SharePoint List and the fields of the item will be obtained from the email body. Make sure, the format of the email body is structured as demonstrated below in the last image.

The console application can be scheduled via Windows Scheduler to run every 5 minutes to check the incoming emails in Outlook.

Read Outlook Emails and Add Email Content in SharePoint List

Please follow the below steps for more detailed information.

Make sure that you have Microsoft Exchange Web Services installed and running. If you do not have Exchange Web Services, you might get an error during compilation.

using Microsoft.Exchange.WebServices.Data;
using MEWS=Microsoft.Exchange.WebServices.Data;

Follow the below steps for installation:

Once you have created a console application and added all the required references, right-click on References and click “Manage NuGet Packages…

read outlook emails and add to sharepoint online

It will open the NuGet Package Manager. Search for “Microsoft.Exchange.WebServices” and when found, select those and click Install.

read outlook emails and add email content in sharepoint list

Create the object of the Exchange Service and provide your Exchange Service credentials. Link your Mailbox with the Exchange Service Object.

ExchangeService oews = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
Credentials = new WebCredentials("akashkumhar","password123","domainname")
}; oews.AutodiscoverUrl("[email protected]");

Here, I have created two folders under Inbox – LetterBox, and SuccessfulItems.

read outlook emails and add to sharepoint list
  • LetterBox – It contains all the Emails which are to be parsed and processed.
  • SuccessfulItems – It contains all the Emails for which the corresponding items are created successfully in the SharePoint List.

The application is designed in such a way that when you send an email to the linked Exchange Email ID, the Inbox rule moves the email received with subject “EmailReader” to the LetterBox so, that the intended emails are only parsed by the code and not the emails in the Inbox.

The console application reads all the unread emails from LetterBox, creates the items in SharePoint list, and moves them to Successful Items.

Make sure the email body is standard for all the emails, as shown below.

read outlook emails and add to sharepoint 2013 list

I have created an Employee list with the below columns and data types for demonstration.

read outlook emails and add to sharepoint 2013

The LetterBox is parsed for all the unread emails and the data is picked from the Email body to be added into the corresponding columns.

I have done a successful implementation of this functionality. Check the below-created list items.

Read outlook emails and add email content in sharepoint list

If I go ahead and show you the “Edit” form of one item, you could see how the field values are correctly placed at their respective fields.

read outlook emails and add to sharepoint

You may like following SharePoint list tutorials:

When you deal with a “Choice” column which is a Checkbox with multiple option values, then you need to handle it differently than other columns. This will consider each option separated by commas as different and mark the checkboxes correctly.