Outlook object model overview
To develop VSTO Add-ins for Microsoft Office Outlook, you can interact with the objects that are provided by the Outlook object model. The Outlook object model provides classes and interfaces that represent items in the user interface. For example, the Microsoft.Office.Interop.Outlook.Application object represents the entire application, the Folder object represents a folder that contains e-mail messages or other items, and the Microsoft.Office.Interop.Outlook.MailItem object represents an e-mail message.
This topic provides a brief overview of some of the main objects in the Outlook object model. For resources where you can learn more about the entire Outlook object model, see Use the Outlook object model documentation.
Applies to: The information in this topic applies to VSTO Add-in projects for Outlook. For more information, see Features available by Office application and project type.
For a related video demonstration, see How do I: Use Outlook to create a custom task report?.
Access objects in an Outlook project
Outlook provides many objects with which you can interact. To use the object model effectively, you should be familiar with the following top-level objects:
The Microsoft.Office.Interop.Outlook.Application object represents the Outlook application, and it is the highest-level object in the Outlook object model. Some of the most important members of this object include:
The CreateItem method which you can use to create a new item such as an e-mail message, task, or appointment.
The Explorers property, which you can use to access the windows that display the contents of a folder in the Outlook user interface (UI).
The Inspectors property, which you can use to access the windows that display the contents of a single item, such as an e-mail message or meeting request.
To help avoid security warnings when you use properties and methods that are blocked by the Outlook object model guard, get Outlook objects from the Application field of the
ThisAddIn class. For more information, see Specific security considerations for Office solutions.
The Microsoft.Office.Interop.Outlook.Explorer object represents a window that displays the contents of a folder that contains items such as e-mail messages, tasks, or appointments. The Microsoft.Office.Interop.Outlook.Explorer object includes methods and properties that you can use to modify the window, and events that are raised when the window changes.
To get an Microsoft.Office.Interop.Outlook.Explorer object, do one of the following:
The Microsoft.Office.Interop.Outlook.Inspector object represents a window that displays a single item such as an e-mail message, task, or appointment. The Microsoft.Office.Interop.Outlook.Inspector object includes methods and properties that you can use to modify the window, and events that are raised when the window changes.
To get an Microsoft.Office.Interop.Outlook.Inspector object, do one of the following:
GetInspectormethod of a specific item, such as a Microsoft.Office.Interop.Outlook.MailItem or Microsoft.Office.Interop.Outlook.AppointmentItem, to retrieve the Inspector that is associated with it.
Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox corresponds to the Inbox folder in Outlook.
For an example that shows how to access a default Folder and create a new Folder, see How to: Programmatically create custom folder items.
The Microsoft.Office.Interop.Outlook.MailItem object represents an e-mail message. Microsoft.Office.Interop.Outlook.MailItem objects are usually in folders, such as Inbox, Sent Items, and Outbox. Microsoft.Office.Interop.Outlook.MailItem exposes properties and methods that can be used to create and send e-mail messages.
For an example that shows how to create an e-mail message, see How to: Programmatically create an email item.
The Microsoft.Office.Interop.Outlook.AppointmentItem object represents a meeting, a one-time appointment, or a recurring appointment or meeting in the Calendar folder. The Microsoft.Office.Interop.Outlook.AppointmentItem object includes methods that perform actions such as responding to or forwarding meeting requests, and properties that specify meeting details such as the location and time.
For an example that shows how to create an appointment, see How to: Programmatically create a meeting request.
The Microsoft.Office.Interop.Outlook.TaskItem object represents a task to be performed within a specified time frame. Microsoft.Office.Interop.Outlook.TaskItem objects are located in the Tasks folder.
The Microsoft.Office.Interop.Outlook.ContactItemobject represents a contact in the Contacts folder. Microsoft.Office.Interop.Outlook.ContactItem objects contain a variety of contact information for the people they represent, such as street addresses, e-mail addresses, and phone numbers.
For an example that shows how to create a new contact, see How to: Programmatically add an entry to Outlook contacts. For an example that shows how to search for an existing contact, see How to: Programmatically search for a specific contact.
Use the Outlook object model documentation
For complete information about the Outlook object model, you can refer to the Outlook primary interop assembly (PIA) reference and the VBA object model reference.
Primary interop assembly reference
The Outlook PIA reference documents the types in the primary interop assemblies for Outlook 2010. For more information, see Outlook 2010 primary interop assembly reference.
In addition to providing information for all of the types in the PIAs, this documentation also provides additional information about the structure of the PIAs and code examples for common Outlook automation tasks.
VBA object model reference
The VBA object model reference documents the Outlook object model as it is exposed to Visual Basic for Applications (VBA) code. For more information, see Outlook 2010 object model reference.
All of the objects and members in the VBA object model reference correspond to types and members in the Outlook PIA. For example, the Inspector object in the VBA object model reference corresponds to the Microsoft.Office.Interop.Outlook.Inspector object in the Outlook PIA. Although the VBA object model reference provides code examples for most properties, methods, and events, you must translate the VBA code in this reference to Visual Basic or Visual C# if you want to use them in an Outlook VSTO Add-In project that you create by using Visual Studio.
|Work with contact items||Provides topics that show how to perform tasks with contacts.|
|Work with mail items||Provides topics that show how to perform tasks with mail items.|
|Work with folders||Provides topics that show how to perform tasks with folders.|
|Work with calendar items||Provides topics that show how to perform tasks with calendar items.|
|How to: Programmatically determine the current Outlook item||Shows how to display the name of the current folder and some information about the selected item.|
Send feedback about: