Working with the Inspector Object
The Inspector window is the window in Outlook that shows detailed information for a particular Outlook item. This is the window that displays when you double-click an item in an Outlook folder. You can have multiple Inspector windows open at any given time.
Working with the Outlook Item Associated with the Inspector
An Inspector window is always associated with 1 of the 15 Outlook item types listed in Table 10-1. To get to the Outlook item associated with an Inspector object, use the CurrentItem property which returns an Outlook item as an object. You can cast the returned object to 1 of the 15 Outlook item types.
Working with an Inspector Window
Table 11-5 lists several properties and methods that are used to set and get the position of an Inspector window as well as some other commonly used properties and methods related to the management of the window.
Working with Different Inspector Editor Types
In the Mail Format page of Outlook's Options dialog, users can set preferences for what kind of formats and editor they want to use when editing an Outlook item. The Options dialog can be accessed using the Options menu command in the Tools menu. Figure 11-6 shows this dialog. Two key options are what message format to use (HTML, Rich Text, or Plain Text) and whether to use Word as the editor of e-mail messages and rich text.
Figure 11-6. Picking formats and editor preferences in the Options dialog.

Adding Buttons and Menus to an Inspector Window
The Inspector object's CommandBars property returns a CommandBars object, which is defined in the Microsoft Office 11.0 Object Library PIA object. Outlook uses the same object model used by Word and Excel to work with buttons and menus associated with an Inspector window. See Chapter 4 for more information on the CommandBars object hierarchy and examples of using the CommandBar objects. Listing 11-9 shows a simple VSTO add-in that creates a toolbar and a button in an Inspector window and handles the click event for the newly added button.
Listing 11-9. A VSTO Add-In That Adds a Toolbar and a Button to an Inspector Window
public partial class ThisApplication
{
Office.CommandBarButton btn1;
private void ThisApplication_Startup(object sender,
EventArgs e)
{
Outlook.MAPIFolder folder = this.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Inspector inspector = this.Inspectors.Add(
folder.Items[1]);
inspector.Display(missing);
Office.CommandBar bar = inspector.CommandBars.Add(
"My Command Bar", missing, missing, true);
bar.Visible = true;
btn1 = (Office.CommandBarButton)bar.Controls.Add(
Office.MsoControlType.msoControlButton,
missing, missing, missing, true);
btn1.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(
Btn1_Click);
btn1.Caption = "My Custom Button";
btn1.Tag = "OutlookAddin1.btn1";
btn1.Style = Office.MsoButtonStyle.msoButtonCaption;
}
void Btn1_Click(Office.CommandBarButton ctrl,
ref bool cancelDefault)
{
MessageBox.Show("You clicked my button!");
}
#region VSTO Designer generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisApplication_Startup);
}
#endregion
}