Outlook Add-ins with Visual Studio Tools for Office
With Visual Studio Tools for Office, you can build add-ins with C# or VB.NET for Outlook 2003 and Outlook 2007. While VSTO adds no new developer functionality to Outlook, it greatly reduces the complexity of building an Outlook add-in.
Versions
The most recent version of VSTO is part of Visual Studio 2008 (all but the Express editions).
The previous release is VSTO 2005 SE (Second Edition), which is a free update for both the original release of VSTO 2005 and most Visual Studio 2005 packages.
What VSTO does
VSTO includes:
- A solution structure that includes both the add-in project itself and a setup project to ease deployment
- Simple Startup and Shutdown events where developers start adding their code
- A runtime component
- An add-in loader that creates the add-in's AppDomain and handles security and some other add-in essentials
Compared with the "shared add-in" (IDTExtensibility2) platform for creating Outlook add-ins, VSTO provides these advantages
- Better debugging experience at design time
- Better error handling at run time
- Graceful add-in shutdown without the need to explicitly manage all COM object references
- Simple Startup and Shutdown events
- Separate AppDomain for each add-in (so that your add-in doesn't stomp on another)
- Stronger security, based on the .NET Code Access Security paradigm
- Integrated form region, task pane, and ribbon designers (Visual Studio 2008)
- ClickOnce deployment support (Visual Studio 2008)
What VSTO does not do is extend Outlook's programmability features with new functionality. You will still be programming against the Outlook object model, using standard Outlook interfaces.
VSTO add-in deployment
The biggest weakness in the first two versions of VSTO was the difficulty of deploying VSTO addins, compared with COM add-ins built with Visual Basic 6 on the shared add-in platform. Visual Studio 2008 has improved the deployment process by adding ClickOnce support.
ClickOnce deployment for Outlook 2007 add-ins
Visual Studio 2008 adds ClickOnce deployment for VSTO add-ins for Outlook 2007. See:
Some useful information on common issues with ClickOnce deployment:
Windows Installer deployment for Outlook 2007 add-ins (VS2008)
For Windows Installer deployment of VS2008 solutions, see:
Deploying an Outlook 2007 add-in to all users
According to Microsoft's Misha Shneerson, to install a VSTO add-in so that all Outlook 2007 users get the necessary keys in the HKCU portion of the Windows registry, you can use an internal Office mechanism that propagates registry values from HKLM to HKCU:
For Outlook 2007 in a Citrix or Terminal Server environment, according to Lily Collins, you need to take care of these three issues:
- Regarding the allusers parameter discussed in the Darryn Lavery article Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer (Part 1 of 2), Table 2, make sure you set the allusers parameter (value="1") so that the security policy is created at the machine level.
- Use the information in the Misha Shneerson article Deploying your VSTO Add-In to All Users (Part II) to identify what changes need to be made to the setup project's default registry entries, e.g. to remove the HKCU entries and add HKLM entries that propagate to HKCU when a user accesses Outlook.
- Create a custom action (create a class derived from the Installer class and create a utility class containing the code that Darryn Lavery wrote and Misha included in his second article) to enable the counter (discussed in Misha's articles) to be incremented.
Deployment for Outlook 2003 add-ins (VS2008)
For VSTO add-ins built with VS 2008 for Outlook 2003, ClickOnce is not an option. Deployment resources are collected here:
Deployment for VSTO 2005 SE add-ins
This is the latest information from Microsoft on how to deploy an Outlook add-in built with VSTO 2005 SE:
Architecture and other additional documentation
Add-in behavior with headless startup
When an external application starts Outlook without displaying any user interface, Outlook is said to be operating in "headless" mode. This article explains how VSTO determines when to load the add-in and why, if your application modifies the toolbar, you need to check Explorers.Count and/or Inspectors.Count in the Startup event:
However, this intended behavior does not work for Outlook 2003 in the original VSTO 2005 SE runtime. It was fixed in a later runtime build; see:
Building add-ins for multiple Outlook versions
With regard to building VSTO add-ins for multiple versions, Microsoft's Misha Shneerson explains that if you build a VSTO project against Outlook 2003, it will work fine on Outlook 2007, because Office 2007 installs a special policy causing Office 2003 PIAs to be "replaced" by Office 2007 PIAs at runtime automatically. For a different point of view, see this article:
Walkthroughs and samples
These samples are available from Microsoft:
Templates from other sources:
These are for Outlook 2003 and the original VSTO 2005 release, not VSTO 2005 SE. You won't be able to open the project files in VSTO 2005 SE, but you should be able to create a new project and then open the other files from these samples:
For additional samples, see:
|