RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Write a Custom Outlook Add-In with Visual Studio Tools for Office

Microsoft's Office software is ubiquitous, highly extensible, and mostly underused. Find out how to capitalize on these features using Visual Studio Tools for Office and start extending Office into new and more productive areas.

isual Studio Tools for Office (VSTO) is an add-on to Visual Studio 2005 that gives developers much more direct IDE support and easier access to the rich programming model provided by the Microsoft Office platform than did previous versions of Visual Studio. VSTO simplifies building applications that use Office's functionality and building add-ins to existing Office applications, such as Outlook or Excel. The ubiquity of the Office platform offers swathes of powerful functionality already on your users' desktops; so you can take advantage of it by reusing the components.

Consider, for example an alerting application. Many companies buy or build alerting applications that send alerts to their users when conditions meet particular criteria—likely through a custom channel to a custom application. If the alert doesn't require an immediate response, users may simply put a notification in their Outlook calendars to handle the alert at a future point. So, for example, when the stock market closes, you may want to be alerted if the stocks you are tracking close above or below your target threshold values. The alert would pop up on your desktop and you would cut and paste the valuable information into an Outlook calendar entry telling you to call your broker before the market opens the following day. After creating the calendar entry, Outlook will throw up a second alert notification the next morning. But when you think about it, that's the only time that you really wanted to be alerted all along, but to get that alert, you had to deal with two alerts for the same event!

Wouldn't it be nice if you didn't need a custom alerting platform to do this? And wouldn't it be even nicer if you didn't have to manually move the metadata associated with the alert into an Outlook calendar item?

This article shows you how to do both using Visual Studio, Office, and VSTO. You'll build an add-in to Outlook that calls a Web service to check stock prices, and compares them against your list of targets (stored in a SQL Server Database). If the price is outside preset thresholds, the add-in creates a calendar entry in Outlook for 8:30 AM on the following day, containing the metadata for the stocks that have fallen outside your desired thresholds. In other words, this application replaces the custom alerting platform (Outlook calendar alerts will handle it for you), you will have a reduced set of alerts (one instead of two), and you don't have to cut and paste to get the alert at the right time.

Figure 1. New Project Templates: After installing VSTO, when you create a new project and select the "Office" project type, you'll see several new project templates.
Getting Started
You'll find the VSTO home page, where you can download a trial edition if you don't already have VSTO installed. When installing VSTO, you'll need to have your Office install disks handy, because you'll need the primary interop assemblies for Office, which are on the Office disks.

After installing VSTO and launch Visual Studio 2005, you'll see several new project templates when you issue a File->New Project command and select "Office" as the project type. See Figure 1.

The available templates allow you to programmatically create a new Excel workbook or Word document, generate a new Excel or Word Template, or create a new Outlook add-in.

In this case, you'll be building an Outlook Add-in so select that template.

Visual Studio will now create a solution containing two projects, one for the Add-in, named OutlookAddIn1 by default, and one for the setup project that installs the add-in on client machines, called OutlookAddIn1Setup by default.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date