The Everywhere Platform
Other than Windows and its default applications such as Notepad and Internet Explorer, what one piece of software is on more desktops than any other? In most companies, the president, sales staff, support staff, office manager, and sometimes even the janitor have Microsoft Outlook installed. The question begs asking then, why do folks only think about email and their calendar when they think about Outlook? Part of the reason may lie in Outlook's COM underpinnings and the dissatisfaction of working with VBA.
While Outlook is still a COM based platform, key advances have made it much more accessible for developers. Since Outlook 2003, Microsoft has provided a set of extensibility tools called the Visual Studio Tools for Office (VSTO). With the release of Visual Studio 2008 and VSTO Second Edition, developers now have powerful tools such as graphical designers and code templates to interact with Outlook's extensibility model.
Outlook's History
In 1997, with the release of Exchange Server 5.5, Microsoft replaced the Exchange client with Outlook.
|
Outlook 97 |
version 8.0 |
Released January 16, 1997 |
|
|
Outlook 98 |
version 8.5 |
Released June 21, 1998 |
|
|
Outlook 2000 |
version 9.0 |
Released June 7, 1999 |
VBA, COM |
|
Outlook 2002 |
version 10 |
Released May 31, 2001 |
VBA, COM, PIA |
|
Office Outlook 2003 |
version 11 |
Released October 21, 2003 |
VBA, COM, PIA, VSTO |
|
Office Outlook 2007 |
version 12 |
Released November 30, 2006 |
VBA, COM, PIA, VSTO SE |
Table 1 - Source Wikipedia
Back then, the only way to interact with Outlook was through custom forms. Microsoft then added extensibility through VBA and COM. Oh, these were the days. Weak types and Object return types. Yum! Like ASP.OLD, we got real sick of this really quick.
PIA – Primary Interop Assemblies
Starting with Outlook 2002, Microsoft started supplying managed assemblies to allow managed code developers to work with Outlook a little easier, and while it did make life easier, it was still no picnic.
VSTO is Born
Beginning with Outlook 2003, Microsoft started shipping the Visual Studio Tools for Office. VSTO provided a wrapper around the PIAs, and made it easier to interact with the Outlook object model. Microsoft has since shipped VSTO Second Edition (SE) for Microsoft Office 2007.
Outlook 2007 Object Model
The Outlook object model is largely contained within two assemblies:
- PIA – Microsoft.Office.Interop.Outlook.dll
- VSTO – Microsoft.Office.Tools.Outlook.dll
To get started with the object model, you should be familiar with the following top-level classes:
You can view interactive diagrams of the complete object model on MSDN: Outlook Object Model Reference
VSTO SE and Visual Studio 2008
VSTO SE for Visual Studio 2008 adds some neat designer templates, such as Ribbon and Form.
Debugging Outlook Add-Ins
Here are a couple tips for debugging Outlook add-ins. First, create a separate profile in Outlook. Next, set up the Debug properties for your project to open Outlook, and pass the profile switch.
Lastly, there is a neat tool called OutlookSpy which can make Outlook debugging and development much easier.
Developing for Multiple Outlook Versions
One project is required for each version of Outlook you wish to target. An OO approach is best here; separate the business logic so it can be included in each project.
Building a Ribbon Add-In
Extending the Outlook ribbon is not unlike Windows Forms development. A ribbon view is displayed in the designer, and can be laid out using drag-and-drop. The designer hierarchy, and the underlying VSTO hierarchy is ribbon, tab, tab group, controls as seen in figure 1. The full range of controls can be found in the toolbox, including
The one caveat of ribbon customization is finding the correct tab or tab group ID. To help, Microsoft has a set of Excel files for download which contain these IDs. The download can be found here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=4329D9E9-4D11-46A5-898D-23E4F331E9AE&displaylang=en
After that, the rest is laying out the forms, and attaching to form elements and the Outlook object model.
|
Ribbon IntelliSense Hack |
|
Note: In order to get Intellisense for the ribbon XML, copy the CustomUI file from C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas\1033\CustomUI.xsd to the Visual Studio schemas directory C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas\ |
Building a Form Region Add-In
Form regions, though similar to the earlier custom forms, are considerably more powerful. Form regions can be added to any inspector window and can help supplement information for the inspector item such as an email or calendar event.
When adding a form region to a project, a wizard is displayed which provides options to create different types of form regions. You have the option to create a separate, adjoining or replacement region, or to replace all the regions in a given area. If you don't like the way the MailItem editor works, you could write your own by using the Replacement region option, and attaching your controls to the underlying object model.
Learning about VSTO and Outlook add-ins opens up a world of possibilities for custom productivity tools, legacy systems integration, and ISV products.