Share via


Outlook object model overview

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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 Application object represents the entire application, the Folder object represents a folder that contains e-mail messages or other items, and the 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.

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:

Application object

The 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 get an instance of the Application object, use the Application field of the ThisAddIn class in your project. For more information, see Program VSTO Add-ins.

Note

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.

Explorer object

The Explorer object represents a window that displays the contents of a folder that contains items such as e-mail messages, tasks, or appointments. The 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 Explorer object, do one of the following:

Inspector object

The Inspector object represents a window that displays a single item such as an e-mail message, task, or appointment. The 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 Inspector object, do one of the following:

Folder object

The Folder object represents a folder that contains e-mail messages, contacts, tasks, and other items. Outlook provides 16 default Folder objects.

The default Folder objects are defined by the OlDefaultFolders enumeration values. For example,

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.

MailItem object

The MailItem object represents an e-mail message. MailItem objects are usually in folders, such as Inbox, Sent Items, and Outbox. 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.

AppointmentItem object

The AppointmentItem object represents a meeting, a one-time appointment, or a recurring appointment or meeting in the Calendar folder. The 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.

TaskItem object

The TaskItem object represents a task to be performed within a specified time frame. TaskItem objects are located in the Tasks folder.

To create a task, use the CreateItem method of the Application object, and pass in the value olTaskItem for the parameter.

ContactItem object

The ContactItemobject represents a contact in the Contacts folder. 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 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.

Title Description
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.