Microsoft outlook is hugely popular email application being used across so many organizations. There can be a no. of reasons why one would like to develop a plugin for it or integrate it with other applications. Microsoft makes it really easy to customize almost all aspect of Outlook using a VSTO addin. In this article, we would look at the basic and some of the advanced options available for Outlook customization by developing a VSTO addin.

Creating the project

Let us start Visual Studio and create a new project of type “Outlook VSTO Add-in” and name it “MyOutlookAddin“. If this project type is not available in your instance of Visual Studio then you might want to install “Office/Sharepoint development” for your VS.

VSTO Addin development

Create a new class “Core” in a new Core.cs file and add the following code. Note that we are making it a singleton class. This is not as such necessarily but we would like to architect our addin this way.

public class Core
{
    private static Core _instance;
    public static Core Instance
    {
        get
        {
            if (_instance == null)
                _instance = new Core();
            return _instance;
        }
    }

    private Core()
    {

    }

    public void Initialize()
    {
        //Instance of the current outlook application
        Microsoft.Office.Interop.Outlook.Application app = Globals.ThisAddIn.Application;
        //Just to show that our addin is loaded
        MessageBox.Show("MyOutlook addin has been loaded!");
    }
}

Now open the file “ThisAddin.cs” and call the initialize method of our core from inside the “ThisAddIn_Startup” function. ThisAddIn_Startup is the first function that is called by outlook once the addin is loaded. Therefore this will be the entry point to our addin.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    //Make sure no exception in our addin should crash Outlook
    try
    {
        Core core = Core.Instance;
        core.Initialize();
    }
    catch (Exception)
    {
        throw;
    }
}

That is it. Close your outlook application if already running and click Run in Visual Studio. Outlook app will start and upon loading our addin will show our message.

Outlook user interface

It is now time for us to familiarize ourselves with what different aspects of an Outlook user interface are called. It will then make it easy for us to look a component into the outlook interop library and customize.

Explorer ribbon

  • Add a new tab here with your own custom commands.
  • Add a context sensitive tab here.
Outlook explorer ribbon
Outlook explorer ribbon

Navigation pane

  • Add a region below the list of all folders. The region can contain your own user control developed in winform.
  • Create your own solution module like the builtin ones (Mail, Calendar). Check out how to create one.
Outlook navigation pane
Outlook navigation pane
Outlook solution folders expanded view
Outlook solution folders expanded view

Folder view pane

  • Create your own custom view for the list of items. Make a default categorization, grouping, sorting etc.
  • Add your own region with custom winform usercontrol above or below the list of items.
Outlook folder view pane
Outlook folder view pane

Reading pane

  • Add your own custom winform usercontrol docked on any side of the pane.
  • Create your custom reading pane for any kind of item.
Outlook reading pane
Outlook reading pane

Inspector window

  • Add your own custom winform usercontrol docked on any side of the pane.
  • Add a new tab to the ribbon.
  • Handle inspector events to invoke your own code.
Outlook inspector window
Outlook inspector window

Inpector ribbon

  • Add a new tab here with your own custom commands.
Outlook inspector ribbon
Outlook inspector ribbon

Context menu

  • Add your commands on right click of any item.
Outlook context menu
Outlook context menu

Adding a new solution module in the navigation pane


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *