Outlook add-ins seem popular again at the moment (we seem to go through phases as to the kind of cases that come in), and one question that has come up a few times now is how to create an add-in that targets both Outlook 2007 and 2010. Fortunately, so long as you are using Visual Studio 2010, this is quite straight-forward. Below is a step-by-step guide for creating such an add-in from scratch. The development machine in this case was Windows 7 with Visual Studio 2010 and Outlook 2007 installed. The guide is also attached to this post as a Word document.
|Development environment is Visual Studio 2010, running on Windows 7 with Outlook 2007 installed.
Create a new Outlook 2007 Add-in project.
|For demonstration purposes, add a messagebox to the ThisAddIn_Startup method of class ThisAddIn.
The add-in will simply display a pop-up to confirm it is loaded when Outlook starts (this will show that the deployment has been successful).
|Change the project configuration to Release, and then build the add-in (this is required to create the files needed for the installer package)|
|Add a new project to the solution, and select Setup Wizard|
|Select Create a setup for a Windows application, then click Next|
|Select Primary output from DemoOutlookAddIn, then click Next|
Add DemoOutlookAddIn.dll.manifest and DemoOutlookAddIn.vsto to the package (these files should be found in the \bin\release folder of the DemoOutlookAddIn project folder).
Right-click the setup package (from Solution Explorer) and select Properties…
Ensure that the required pre-requisites are selected. These are:
Click OK, then OK again to get back to the main Visual Studio IDE.
|Expand Detected Dependencies (in Solution Explorer), and exclude all dependencies except Microsoft.Office.Tools.Common.v4.0.Utilities.dll and Microsoft.Office.Tools.Outlook.v4.0.Utilities.dll|
|Select DemoOutlookAddInSetup in Solution Explorer, then ensure InstallAllUsers property is True. You can also adjust other properties as needed (such as author and manufacturer). Note that the Manufacturer property determines the folder into which the add-in will be installed under Program Files.|
|Right-click DemoOutlookAddInSetup in Solution Explorer, and select View then Registry.
Add the registry settings as shown to register the add-in into Outlook.
|Add the EnableLocalMachineVSTO registry setting. Note that this is required for Outlook 2007 to enable add-ins to be installed to HKLM. Also required is hotfix 976477 (http://support.microsoft.com/kb/976477) as detailed in KB 976811 (http://support.microsoft.com/kb/976811).
The hotfix must be installed for this deployment package to work with Office 2007.
|Delete any redundant registry keys (there are a couple created automatically under HKEY_CURRENT_USER).|
That's it! You can now build the setup package and deploy to multiple clients.