Tuesday 12 October 2010

Creating Microsoft Outlook 2007 Add-Ins with Visual Studio 2008

From the 2008 version of Visual Studio, VSTO (Visual Studio Tools For Office) was included as started in all versions from Professional upwards. Previously it had been a separate add-in, with limited functionality in the pro version of Visual Studio.

To create an add in for Outlook 2007;
1) Oen visual studio 2008, go to File\New Project
2) From the project tree Choose Visual Basic\Office 2007\Outlook Add In




3)




4) To add an event handler, select Application from the drop down on the left, which lists elements of the class. Then select the event from the event list on the right.

5) Take as an example, ItemSend event

6) Add some code to the item event

7) Run the project in the usual Visual Studio way, Outlook will start, and the add in will be installed, so if you try to send an email message, your event will fire.

8) One great thing here is that you can set breakpoints within the code in Visual Studio, and do the usual debugging, while events are being fired in Outlook. This is an advance over the VBA methods of older versions of Outlook.

9) To remove the add-in from Outlook during the development stage: in Visual Studio Debug: Clean

No comments: