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.
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
- 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. Still, deployment is the biggest problem for VSTO developers, especially when supporting several Office versions: in this case you need to deploy different VSTO RunTime versions. Add-in Express abandoned the VSTO editions of their tools in favor of Add-in Express for Office and .net. Have a look at their Office add-in deployment options.
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:
All-in-one platform for developing Microsoft Outlook plug-ins that work for all versions, from Outlook 2000 to 2013, both x86 and x64.
Allows developers to switch security warnings off and back on with a couple of simple code statements. .NET, ActiveX and VCL editions are delivered in one package.
VSTO Power Tools
VSTO 2005 SE
VSTO 2005 SE Update - increases compatibility with Windows Vista and, according to Microsoft, resolves a problem with Outlook 2003 not loading a VSTO add-in when Outlook is started without a user interface (for example, by a PDA synchronization application)
VSTO 2005 SE Runtime - version 8.0.50727.891, released 9 Sep 2007, includes fixes for Outlook add-in support
Outlook Add-in Snippets
Visual Studio Tools for Office forum -- discuss issues related to VSTO add-in architecture and deployment with Microsoft experts and other developers
OutlookCode.com .NET forum -- discuss issues related to writing Outlook code in VB.NET and C#
OUTLOOK-DEV discussion list