Create an add-in for Outlook 2007 and 2010 in one solution


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.

 

New Project Development environment is Visual Studio 2010, running on Windows 7 with Outlook 2007 installed.
Create a new Outlook 2007 Add-in project.
Code 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).
Configuration 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 New Project Add a new project to the solution, and select Setup Wizard
Choose a project type Select Create a setup for a Windows application, then click Next
Choose project outputs to include Select Primary output from DemoOutlookAddIn, then click Next
Choose files to include

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).

Click Finish.

Project Property Pages

Right-click the setup package (from Solution Explorer) and select Properties…

Click Prerequisites…

Prerequisites

Ensure that the required pre-requisites are selected.  These are:
Microsoft .NET Framework 4 Client Profile (x86 and x64)
Microsoft Office 2007 Primary Interop Assemblies
Microsoft Visual Studio 2010 Tools for Office Runtime (x86 and x64)
Windows Installer 3.1

Click OK, then OK again to get back to the main Visual Studio IDE.

Detected Dependencies 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
Project properties 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.
Registry - add-in Right-click DemoOutlookAddInSetup in Solution Explorer, and select View then Registry.
Add the registry settings as shown to register the add-in into Outlook.
EnableLocalMachineVSTO 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.
Registry - redundant 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.

 

Creating an add-in.docx

Comments (6)

  1. James Cameron says:

    I have installed Outlook 2010 instead of 2007 but I would like to develop for both outlook.

    Did you test with  Windows 7 with Visual Studio 2010 and Outlook 2010 installed?

    It is possible to debug from VS2010 for outlook 2010 then in a virtual machine for outlook 2007 ?

    Thank you in advance for your answers.

  2. I tested the deployment package above on both Windows 7 and Vista, with both versions of Office.  I developed the add-in on a Windows 7 machine with Office 2007 installed.

    If you are creating an add-in that targets multiple versions of Office, then the best approach is to develop it against the earliest Office – this should prevent you from inadvertently using features that aren't available in later versions.

    Having said this, if you have two machines each with a different version of Office, you should be able to load up the solution and debug in whichever version of Office you are using on that machine.

  3. Garrydene says:

    Excellent information thank you –

    Placing the reg keys in user/machine has made the difference for me.

    "User/Machine Hive: Use this registry setting when you might have different users on the same machine with different access permissions running the installation application. Any registry keys in this registry section are automatically moved to the HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE and/or HKEY USERS section based on permissions and installation selections"

  4. Sanket says:

    Hello,

    Can you tell me please steps require for deploying Outlook addin setup on x64 OS and x86 Office outlook machine?

    You above steps are not working on x64 OS and x86 Office outlook machine.

    Thanks,

  5. Pradip says:

    I have a outlook 2010 addins project that is developed in visual studio 2012. Now i need the solution for outlook 2007 also. I have tried by editing the exe path in .csproj file. The project executes but the addin doesn not appear.

    Please give me some ideas. What should i do to run my solution in outlook 2007 also.

  6. Mike Wykhuis says:

    If you have issues fetching config file entres from your app.config file, please change your HKLM maniest path from '[TARGETDIR]….' to 'file:///[TARGETDIR]…'    In my case my db connection string was in the app.config file and my outlook addin could not access the manifest file to get at the app config file properly.    My outlook addin gets installed to the program files folder and I'm using office 2007 with 2010 visual studio tools for office.  Other than that, this blog rocks.

Skip to main content