Friday, September 18, 2009

Adding custom pane to Outlook with VSTO SE

Today i am going to explain about Adding a new pane onto Outlook 2007. I searched MSDN articles for the same, but i never found a suitable one.

Prerequisites: To complete this walk-through, you will need:
1) Microsoft Visual Studio 2005

2) VSTO 2005 SE
3) Microsoft Outlook 2007


Start the visual studio 2005. Create a new project of type Outlook 2007 Add-in.

VSTO
Visual studio automatically adds the deployment project for the add-in. You will be presented with a partial class called ThisAddin. It has ThisAddIn_Startup & ThisAddIn_Shutdown which occurs when your outlook addin gets loaded and unloaded respectively.

To add a Panel onto outlook is pretty straight forward.
1) Add a user control by right clicking on your Project.
2) Name the user control as TaskPanel
3) Now drag some controls from toolbox on to the user control like some textbox, radio button etc.

If you have followed my steps, your visual studio should appear like the one below.

Usercontrol

 

Add these namespaces in ThisAddin.cs
using Microsoft.Office.Tools;
using Microsoft.Office.Interop.Outlook;

using Microsoft.Office.Core;

Add these global variables in
ThisAddin Class.

Microsoft.Office.Tools.CustomTaskPane taskPane;
Outlook.Explorer explorer;


Replace your ThisAddin_Startup method by this one.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
explorer = this.Application.ActiveExplorer();

taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new TaskPanel(), "Demo", explorer);
taskPane.Visible = true;
taskPane.Width = 245;

//You can set the docking position of the Panel
taskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;

//You can also restrict the docking position change.
taskPane.DockPositionRestrict = Microsoft.Office.Core.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNone;
}


Replace your ThisAddIn_Shutdown by the one below.

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
this.CustomTaskPanes.Remove(taskPane);
this.Application = null;
}

Your ThisAddin class should be similar to this one.


ThisAddin


Build and run your project. It opens the outlook and your panel should be displayed on right side of outlook.


Outlook Panel



If you think Visual studio has made it very much easy to deploy the add-in, Think again :)
Deploying the Add-in on another computer needs quite modification to the deployment setup project. Read Deploying VSTO using Visual Studio

You can download the project from Outlook Panel in VSTO

3 comments:

Anonymous,  Monday, 22 March, 2010  

Hi,

Nice article !!

I want to send my Custom Form as e-mail in outlook.
Say i submit a from & it goes to my superior for Approval - now i want that when my superior clicks on the notification e-mail, the Approval form should directly be opened.

Can you help me achieving this ?

Ganesh Friday, 13 August, 2010  

cool posting.. i was searching for this solution for a longgg time. Thanks a lot....

Manthena,  Friday, 28 January, 2011  

Could you please let me know how to disable title bar for this pane.

Popular Posts

Blog Archive

About Us

Share this Page

  © Internet Blues

Back to TOP