OUTBOX: Introduction to Exchange Store Event Sinks Part 2

  • Comments 5
Coming from Exchange 5.5 Event Service Scripts to Exchange Store Event Sinks involves more than just understanding the new events available and the registration process.  Exchange 5.5 event scripts are written in VBScript with CDO 1.21 as the API to interact with Exchange data.  Store Event Sinks can be written in VBScript, VB6, managed (.NET) code, and C++ they use ExOLEDB with ADO and CDOEX to interact with Exchange data.  This is greatly improves scalability and performance but requires a bit of retooling for the developer to be comfortable in their new surrounds.  The following information discusses what you need to know about the web store how to interact with data using CDOEX and ExOLEDB.
 
Exchange Store
 
One important distinction to make between Exchange 5.5 and Exchange 200x is the storage architecture.  This is an important consideration when looking at the new API's available in Exchange 2000 and 2003 because many of the new API's relate to what is called Web Store or stream database that is added to the Exchange storage system.  Exchange store event sinks, WebDAV, CDOEX, and ExOLEDB with ADO all work against the web store primarily as opposed to CDO 1.21 and MAPI which work against the ESE database (which was part of Exchange 5.5 as well and is commonly referred to as the MAPI database).  We will talk about ExOLEDB and CDOEX mainly because that is what you will use in an Exchange Store Event Sink.
 
Exchange Storage Architecture
 
 
CDOEX, ADO, Properties, and Exchange SQL
 
The web store uses native intermittent content such as MIME which allows access through ExOLEDB with ADO and WebDAV and the use of SQL-like queries to find information.  This is quite helpful and a little more intuitive for the database programmer.  Each item (folders and messages) in the store can be created, modified, and searched like a row in a database were item properties are columns. 
 
Folders can be used like tables and rows, for example to query the subfolders of a given root folder you would select the URL from all items in the root folder where the item "isFolder" column is "true"...
Select "DAV:href" from scope('shallow traversal of <ROOT FOLDER URL>) Where "DAV:isfolder" = True
The following link provides a description of the SQL predicates supported against the web store.
 
Exchange Store SQL
 
Add just like in a database when you write a query like the one of above you need to know two key pieces of data specific to your store, the table name and the available columns.  The table name is pretty easy to identify as it is the folder you what to query from.  The column names differ for each item type with some overlap.  For example appointment items and contact items have most of the same properties of a basic message but they also have their own unique properties that relate to their functions.
 
The following link provides a listing of properties available on different items organized by namespace.  You will use the full namespace and property name when pulling fields from the Fields collection of a CDOEX object or querying in WebDAV or ADO.
 
Properties by Namespace
 
The interesting thing about this paradigm is that it is often quite easy for a database developer to walk in and start using ExOLEDB with ADO and WebDAV to execute these kind of queries against Exchange.  However, a developer coming from MAPI or CDO 1.21 is usually left looking for the objFolder.Folders collection.  ExOLEDB with ADO and WebDAV provide a way to retrieve raw information from the server, they are not an object model.  CDOEX provides some interfaces and CoClasses to provide a bit of an object model for interacting with the web store.
 
MSDN Reference for CDOEX CoClasses, Interfaces, etc.
 
In event sink development you will typically stay within the interfaces of the CDOEX object you open with the URL passed into the event interface.  Especially when working with meetings and contacts note that CDOEX provides a supported way for working with these item types.  ExOLEDB with ADO and much of WebDAV offers you raw access to the items in the web store, complex item types like appointments and contacts require CDOEX or special WebDAV commands to ensure that all the appropriate properties are being set to ensure that end user clients display and use the information appropriately.
 
It is important to understand the limitations of each API and where you should use which.  CDOEX and ExOLEDB with ADO should only be used on an Exchange server, specifically they can only be used the Exchange server which hosts the mailboxes or public folders you want to access.  WebDAV should be used to remotely access Exchange mailboxes and folders that may not reside on the server it is running on, it can also be executed on a non-Exchange server.  All of these technologies are supported with managed (.NET) code, CDO 1.21 and MAPI are NOT supported with managed code.
 
813349 Support policy for Microsoft Exchange APIs with the .NET Framework applications
http://support.microsoft.com/default.aspx?scid=kb;EN-US;813349
 
Examples
 
Exchange Tasks
This is a great starting place when you are looking to see what you can do with Exchange API's.  There are all kinds of great code samples here to allow you to do all kinds of stuff against the store.  I have pulled a couple samples out that relate to some common tasks developers do inside event sinks.
 
Adding an Appointment to the Calendar
 
Responding to a Meeting Request
 
Listing Inbox Contents Using ADO
Page 1 of 1 (5 items)