What's new in Outlook 2007 Object Model

The following document summarize the new important additions to the object model of Outlook 2007, relatively to previous versions of Outlook.

The Accounts Collection

In all previous versions of Outlook, the object model didn't provide any interface for enumerating all accounts on the current profile. Programmers who want to get essential information about the accounts (Like email, type of account, and so on) had to read the information directly from the Registry - under HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Profile Name.
After Outlook 2003 release, Microsoft introduced new set of COM interfaces named "Account Management API". The IOlkAccountManager::EnumerateAccounts method allow programmers to enumerate all accounts, but... These interfaces are based on IUnknown interface and Microsoft doesn't provide C++ headers files for these interfaces, which means that only very experience C++/COM programmers can find out how to use them...

In Outlook 2007, Microsoft finally decided to make the life easier, and add a new Accounts collection under NameSpace object. Each Account object under this collection provide the following properties:

  • AccountType: Returns OlAccountType that specifies the type of the account: olExchange, olImap, olPop3, olHttp, or olOtherAccount.
  • DisplayName: Returns a string that specifies the account display name.
  • SmtpAddress: Returns a string that specifies the SMTP email address of the account.
  • Username: Returns a string that specifies the user name of the account.

The Stores Collection

Another important collection that added in Outlook 2007 is the Stores collection, under NameSpace object. In previous versions, programmers that wanted to enumerate all stored under the current profile had to choose from one of the following methods:
  • Enumerate all top level folders with Outlook object model, extract the StoreID of each folder, and then use CDO or MAPI interfaces to get more information about each store.
  • Enumerate the InfoStores collection of CDO session object, and then use the fields collection of InfoStore object in order to get more information about each store.
  • The hardest way: Use extended MAPI call (In C++): IMAPISession::GetMsgStoresTable.
The Stores collection in Outlook 2007 provides an easy way to enumerate all stores. Each Store object in the collection, provide the following properties and methods:
  • DisplayName: Displayed name of store.
  • ExchangeStoreType: Returns OlExchangeStoreType that specifies the type of Exchange store - olPrimaryExchangeMailbox, olExchangeMailbox, olExchangePublicFolder (if the store contains public folders) or olNotExchange (if it's not a store of Exchange Server)
  • FilePath: Returns the path of the pst file (For non-Exchange stores).
  • IsCachedExchange: Specfies whether the store in in cached mode. (Only for Exchange stores)
  • IsDataFileStore: Specfies whether the store has a pst file.
  • IsOpen: Specfies whether the store is currently opened.
  • StoreID: Specfies the StoreID of the store.
  • PropertyAccessor: Allows the programmer to access other properties of the store.
  • GetRootFolder Method: Returns a Folder object that represents the root folder of the store.
  • GetRules Method: Returns a Rules collection for the specified store.
  • GetSearchFolders Method: Returns a collection of search folders under the specified store. In previous version of Outlook, Search Folders could not be accessed directly from the Outlook Object Model without using MAPI or CDO.
To access the default store of the current profile, use the DefaultStore property on NameSpace object.

The Rules Collection

Outlook Rules is very important feature that allow the users to filter unwanted emails, as well as executing other actions when email with a specified criteria is arrived. (For example: a user can choose to play a sound when he receive an email from his friend)
In previous versions of Outlook, programmers could not create or access the rules of Outlook from the object model. In Exchange 5.5 SDK, Microsoft introduced a COM library, rule.dll, that allowed programmers to access and create rules, but this library only worked with server-side rules on Exchange server, as well as this library is quite old, and Microsoft haven't updated it for years.

The new Rules collection of Outlook 2007 allows the programmers to easily create and access the rules of Outlook. The Rules collection is accessible from Store object by using GetRules method.
Each Rule object in the rules collection provide the following properties and methods:

  • Conditions: Conditions collection of this rule (RuleConditions object)
  • Exceptions: "Except if..." Conditions collection of this rule (RuleConditions object)
  • Actions: Actions collection of this rule (RuleActions object)
  • Enabled: Allow you to enable or disable the rule.
  • ExecutionOrder: An integer value that represents the execution order number, relatively to the other rules.
  • IsLocalRule: Returns True if this rule is executed on the client or False is this rule is executed on Exchange server.
  • Name: The name of the rule.
  • RuleType: Returns OlRuleType. olRuleReceive if the rule is for received emails or olRuleSend if the rules are for sent emails.
  • Execute Method: Allows you to execute the rule programmingly.

New methods and properties in NameSpace class

In addition to the collections mentioned above, there are more new properties and methods in NameSpace class:
  • CurrentProfileName: Returns the current profile name.
  • DefaultStore: Returns the Store object of the default Store.
  • ExchangeMailboxServerName: Returns a string that specifies the Exchange server name (Only if profile is connected to Exchange Server)
  • ExchangeMailboxServerVersion: Returns a string that specifies the Exchange server version (Only if profile is connected to Exchange Server)
  • CompareEntryIDs Method: Compares 2 EntryID strings and returns True if they represent the same Outlook item.
  • CreateSharingItem Method: Creates a new SharingItem object. SharingItem is a new type of Outlook item added in Outlook 2007.
  • GetAddressEntryFromID Method: Returns AddressEntry object according to the specified ID parameter.
  • GetGlobalAddressList Method: Returns an AddressList object that represents the Global Address Book.
  • GetStoreFromID Method: Returns a Store object according to the specified StoreID parameter.
  • SendAndReceive Method: Initiate "Send And Receive" action. The method accept one parameter that specify whether a progress dialog-box should be displayed.

New properties and events in Application class

The most significant change in the Application class is the new context-menu events. These events can be useful if you want to add new menu items to the context menus of Outlook.
  • DefaultProfileName Property: Returns the default profile name. In previous versions of Outlook, this value can be extracted from the Registry.
  • AttachmentContextMenuDisplay Event: Occurs when the attachment context-menu is about to be displayed.
  • FolderContextMenuDisplay Event: Occurs when the folder context-menu is about to be displayed.
  • ItemContextMenuDisplay Event: Occurs when the context-menu of item is about to be displayed.
  • ShortcutContextMenuDisplay Event: Occurs when a shortcut context-menu is about to be displayed.
  • StoreContextMenuDisplay Event: Occurs when a store context-menu is about to be displayed.
  • ViewContextMenuDisplay Event: Occurs when a view context-menu is about to be displayed.
  • ContextMenuClose Event: Occurs when a context menu is closed.
  • ItemLoad Event: Occurs when an item is loaded.

New properties and methods in AddressEntry class

The most significant change in the AddressEntry class is the Exchange Server support. In previous versions of Outlook, AddressEntry object didn't work well with address entries on Exchange server. In particular, there was a problem with retrieving the real SMTP address (like user@domain.com) of Exchange account, and programmers had the use CDO or MAPI in order to achieve this task.
With the new object model, retrieving the SMTP address of Exchange account is much easier - Just get the ExchangeUser object by using the GetExchangeUser method, and then from the ExchangeUser, retrieve the PrimarySmtpAddress property.

Here's the list of all new properties and methods in AddressEntry class:

  • AddressEntryUserType: Returns the type of address entry. You can use this property to distinguish between Exchange address and non-Exchange address. For Exchange addresses, use GetExchangeUser and GetExchangeDistributionList methods for getting more address details.
  • PropertyAccessor: Returns a PropertyAccessor object that allows you to access other properties.
  • GetExchangeDistributionList Method: Returns ExchangeDistributionList object that provides more information about Exchange Distribution List.
  • GetExchangeUser Method: Returns ExchangeUser object that provides more information about Exchange address entry.
  • GetContact Method: Returns a Contact object for this address entry.

New object model for Outlook Views

In previous versions of Outlook, there is only one View class, and the only way to change the definition of the view is by setting the XML property.
In Outlook 2007, there are 6 new View classes that inherit from the main View class, and provide properties and method to manipulate the view definitions.
Here's the list of new View classes available in Outlook 2007 object model:
  • TableView class for table views (ViewType = olTableView).
  • CardView class for card views (ViewType = olCardView).
  • BusinessCardView class for business card Views (ViewType = olBusinessCardView -> New view type added to Outlook 2007).
  • CalendarView class for calendar views (ViewType = olCalendarView).
  • IconView class for icon views (ViewType = olIconView).
  • TimelineView class for timeline views (ViewType = olTimelineView).

The PropertyAccessor class

In previous versions of Outlook, programmers that wanted to access extended properties that are not available in the Outlook Object Model, had to use CDO or MAPI.
In Outlook 2007, many classes, including MailItem, TaskItem, ContactItem, Folder, Store, AddressEntry, Attachment, and more, provide an instance PropertyAccessor object. With PropertyAccessor object, programmers can easily get and set values of all MAPI properties without need to use CDO or MAPI interfaces.

Items enumeration with Table object

Outlook 2007 object model provide a new and faster way to enumerate a folder with large amount of items. Instead of accessing the Items collection, a programmer can call the GetTable method under a Folder object. For more information about using the new Table object, read here.

New form customization and control classes ("form regions")

Outlook 2007 introduce completely new form customization, known as "form regions". The new forms also provides a new set of controls classes: OlkDateControl (Date picker control), OlkTimeControl (Time picker control), OlkCategory (Category control), and more...

New Outlook item class

In addition to existing Outlook item classes (MailItem, TaskItem, ContactItem, and so on...), there is a new item class added to Outlook 2007: SharingItem class. A new sharing item can be created by using CreateSharingItem method in NameSpace object.

More Information...

To get more information about the new Outlook Object Model, read the following articles in MSDN Web site: