Digital Solutions Blog

Dsg Subscribe Mail Web

Blogs (Digital Solutions Blog) (Digital Solutions Blog)

SharePoint 2013 Custom Web Part Farm Solution

Swetha Chinnari
6 Months Ago

It 's frustrating to be navigating back and forth between the many business applications we use on a daily basis.  In SharePoint 2013, a custom web part farm solution can be built for access to multiple applications in one place- a great convenience for users.  I'll explain the process to build this and provide you with an introduction to creating a Custom multi-email web part that will display the emails from your O365 account, Outlook etc in a single app that sits right on your SharePoint site.  A more detailed explanation will be provided in a Part 2 of this post.

Before we get into too much detail, we first need to get familiar with creating a simple custom Web Part for SharePoint 2013. Refer to the below easy steps below to build your app and deploy it to SharePoint 2013 farm.

Step 1 - Create a SharePoint 2013 Visual Web Part Project

                The first step is to create your project solution. To do this open your visual studio 2012 or later version and create a new project. Refer to the below image to create the project solution:

 

Step 2: Add Site URL and select farm option

 

 

Step 3: Add a label in your .ascx file and add assign it in your code behind like this.

Your code behind the file will have a naming convention like this: [project name].ascx.cs

Place the below code in the Page_Load function:

Step 4: Save and click start

Step 5: Upload and Activate .wsp

You should be able to find the .wsp file in the windows explorer where the project is placed. It will be under Bin\Debug with extention .wsp.

Once you are all set with .wsp file navigate to Site Settings on SharePoint site -> Solutions and upload the wsp and make sure to activate the solution

 

Congratulations! Now the newly created web part can be added to any web part page from the web part gallery.

 

Next Step

In this step I would just like to give you enoigh information to leverage creative skillset in developing a multi-mail web part for SharePoint 2013.

In order to create an email web part, you will need to get the authentication information from SharePoint and pass it to the O365 and EWS api to get the emails.

Use the Office365 REST v1.0 API at https://outlook.office365.com/api/v1.0 access the emails from the O365 mail server and use the EWS managed  API to access the emails from the other Microsoft exchange email servers.

Hint: C# code to fetch O365 emails

  string password = "abcd";

  string username = "something@something.com";

  string baseUrl = "https://outlook.office365.com/api/v1.0/";

  UsersEmailModel emailmodel = new UsersEmailModel();

  var usersemails = emailmodel.GetAllUserEmails(password, username, baseUrl);

 

I wanted to keep this post brief yet give you enough information to get started with your custom SharePoint 2013 web part. I will explain the multi-email webpart in detail in Part 2 of this post- coming soon.

Hope you enjoy using and customizing SharePoint as much as I do!

Thanks for reading!