I had a customer who required information and advice on creating an addin for their environment.

Their requirements were to create a button in the Appointment window which simply launches a web page (used to book a meeting room through an internal web application). The URL for this web page would use the start date of the Appointment, so the add-in has to be able to retrieve this start date before launching the web page.The customer wanted information on how to develop this for Outlook. They wanted to use VS2008 but specifically target for Office 2003 and Office 2007 clients.

Here are the examples, code that were sent to them to assist them.

This aricle would help provide an understanding of how commandbars work in Outlook
201095 OL: How to Use CommandBars in Outlook Solutions

This article provdes bacgroun dinformation on programmming the Office Environment:
306130 How To Create Office COM Add-Ins by Using VBA and Office Developer

Article on coding using VSTO with Office

Developing Office Solutions

Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0)

Programming Application-Level Add-Ins

Walkthrough: Creating Your First Application-Level Add-in for Outlook

Outlook Object Model Overview

provided a coded sample for the customer to implement in their environment.
The code below tested on a Windows xp3, Outlook 2003 sp2 with Visual Studio 2008 sp1

The Office PIAs (Primary Interop Assemblies) are required for programmatic to office libraries and need to be installed when targeting for office 2003. This is accomplished by running the Office setup program and choosing .NET programmability support.
Click Start | Control Panel |Choose Microsoft Office Professional Edition 2003 and click ‘change’
- This will start the office setup process
Click Add or remove Features and choose ‘next’
Click the checkbox - choose advanced customization of applications and ensure all the products are selected (at least Outlook), then click ‘next’
You will see Microsoft Office Outlook in the list so expand this
The first entry will be .NET Programmability Support, choose this and popup will appear confirming you wish to ‘Run from My Computer’
Click on update and  the office setup will install the Outlook PIAs

Start your Visual Studio Environment and click new project, the new project dialog will appear
You will see Office and the Visual Studio Installed templates
Choose Outlook 2003 Addin
This will start the project environment.
‘ replace the class with the code below

using System;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Collections.Generic;

namespace Elia.Omr2007
    public partial class ThisAddIn
        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);


        private List<object> objectsToRelease = new List<object>();

        private void ThisAddIn_Startup(object sender, EventArgs e)
                Inspectors inspectors = this.Application.Inspectors;
                inspectors.NewInspector += new InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
            catch (System.Exception exc)
                MessageBox.Show(exc.ToString(), "Exception...");

        private void ThisAddIn_Shutdown(object sender, EventArgs e)
                foreach (object objectToRelease in this.objectsToRelease)
            catch (System.Exception exc)
                MessageBox.Show(exc.ToString(), "Exception...");

        private void Inspectors_NewInspector(Inspector inspector)
            AppointmentItem appointment = null;
            CommandBars inspectorCommandBars = null;
            CommandBar eliaCommandBar = null;
            CommandBarControls eliaCommandBarControls = null;
            CommandBarButton meetingRoomButton = null;
                appointment = inspector.CurrentItem as AppointmentItem;
                if (appointment != null)
                    inspectorCommandBars = inspector.CommandBars;
                    eliaCommandBar = inspectorCommandBars.Add("EliaOMR", 1, false, true /*this makes the command bar temporary, no cleanup needed*/);

                    // Add a button to the command bar and create an event handler.
                    eliaCommandBarControls = eliaCommandBar.Controls;
                    meetingRoomButton = (CommandBarButton)eliaCommandBarControls.Add(1, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                    meetingRoomButton.Style = MsoButtonStyle.msoButtonCaption;
                    meetingRoomButton.Caption = "Meeting Rooms Reservation...";
                    meetingRoomButton.Click += delegate(CommandBarButton ctrl, ref bool cancel)
                        DateTime startTime = appointment.Start;
                        string url = string.Format("http://meetingrooms.elink.elia.be/site/RedirectFromOutlook.asp?newdate={0}&screenres=640", startTime.ToShortDateString());

                    eliaCommandBar.Visible = true;
            catch (System.Exception exc)
                MessageBox.Show(exc.ToString(), "Exception...");

        private static void Release(object value)
            if (value != null)

It is crucial that calls are made to Marshal.ReleaseComObject; without them all sorts of random errors can apparently occur. So best include cleanup code in any COM interop stuff you develop. here is a explanation for that:
Outlook Item leaks

Customer also wanted to know that after all this,what solutions we had for deploying their addins to their clients. Here is a bunck of links provided to help customers with deployment and a tool that you could use to help diagnose potential client side issues.

Introduction to Interoperability Between COM and .NET

Deploying Office Solutions

Troubleshooting Office Solution Deployment (2003 System)

Microsoft Visual Studio 2005 Tools for Microsoft Office System: Microsoft PSS VSTO 2005 Client TroubleShooter