Read an Excerpt
Chapter 1: Introducing the CDO Libraries
So what is CDO? Well, it stands for Collaboration Data Objects, and is essentially a set of object libraries you should use if you want to do any of the following:
- Write a web-based message board for intranet users.
- Automatically send mail to track sales and orders for your products.
- Centralize contact information to let all your users share a contact database.
- Add a guest book to your web site.
- Implement an automated response system to handle frequently-asked helpdesk questions.
- Set meeting rooms to automatically display relevant information for the upcoming meeting.
- Monitor server status and send warning mail to the administrator when problems arise.
And that's far from all you can do - from something as simple as automatically mailing customers when a product upgrade is available, to something as complex as implementing an entire web-based collaboration and messaging system, CDO will provide you with the tools you need.
In order to work with CDO libraries, you'll need a message store. Microsoft Exchange Server provides a message store architecture ideally suited to storing multiple messages and accessing them rapidly in exactly the way that mail-enabled applications require - while standard database servers may have more versatility, they are not fundamentally designed to handle mail transportation and storage from the ground up, as Exchange Server is.
Key to our choice of running CDO samples against Exchange is the fact that while CDO should work with any Messaging Application Programming Interface (MAPI) compliant system, it uses manyExchange-specific features to manage and access the data. This creates problems when you use CDO libraries with messaging systems other than Exchange.
In this chapter, we'll be looking at:
- A historical recap of the development and origins of CDO
- An overview of the different flavors of CDO
- Where to get the different CDO Libraries
- A list of which products include which CDO version
- A brief glance at the features of each library and what they're all for
First, it would be a good idea to look at what collaboration actually is.
What is a Collaboration Application?
In today's business world, companies need to communicate effectively to gain and maintain competitive advantages. Internally, they need to coordinate activities involving different business units. Externally, they need to establish and improve good relationships with customers and suppliers. Modern interpersonal messaging technologies such as telephone, fax, and e-mail provide reliable and efficient services to satisfy our needs.
The IT industry continues to provide the infrastructure necessary to allow businesses to communicate and collaborate. Microsoft Exchange Server, Lotus Notes, and other messaging systems offer reliable and powerful services for people and organizations to communicate with each other, while messaging clients such as Microsoft Outlook allow people to maintain contact information, send and receive messages, organize schedules and meetings, and share information. Collectively, messaging servers and clients form collaboration applications that spread over local area networks, wide area networks, and the Internet.
While shrink-wrapped applications provide the capability for users to perform common tasks, there is always demand for customized applications that best satisfy the specific requirements of an organization. Building such collaboration applications requires the ability to programmatically access message stores and manage messaging data. The Microsoft CDO 1.21 and CDO Rendering libraries provide well-defined object models that allow application developers to communicate with Microsoft Exchange Servers and provide users access to data stored on those servers.
The Origins of CDO
Given its full name - Collaboration Data Objects 1.21 Library - it wouldn't be particularly surprising if you believed that CDO was a fairly new technology. In this guise it may be, but in the long view, CDO is actually Microsoft's fourth generation Messaging API.
While Microsoft provided a variety of mail systems in the past, the first one that included any sort of API for programmers was Microsoft Mail 3.0 for Windows, released for Windows 3.0, 3.1 and 3.11 (Windows for Workgroups). This e-mail system introduced the Simple Messaging Application Programming Interface, or Simple MAPI for short.
At the time, it was actually just called MAN, but with the introduction of Extended MAN a while later, the original interface was renamed to avoid confusion.
Simple MAPI provided very basic functionality - you could log in and out of the system, read messages from your inbox, view the address book, and send plain text messages with file attachments. This may not seem like a lot, but at the time it was a great step forward - it meant that applications supporting Simple MAPI such as Word 2.0 could now have, for instance, File I Send... menu options.
Simple MAPI is still useful if you want to write very simple mail applications, and is still supported - for instance the Microsoft MAPI controls for Visual Basic are just a wrapper for Simple MAPI, and you can even use the functions directly from Visual Basic if need be.
What's more, remnants of the original API still remain - the original mail systems used a separate password to protect your mailbox, and you will still find a password argument used in the logon methods of CDO, even though now it serves no purpose. We won't look at Simple MAPI in this book, but it's an important part of the history of CDO.
Purely for historical completeness, it would be rude not to mention the CMC (Common Messaging Calls) API. This was another simple messaging API, specified by the XAPIA consortium - the group behind the X.400 specification. CMC was intended to be usable with any mail system; programmers would write to the CMC API, and versions of CMC would then talk to the different underlying mail systems as appropriate, be it Microsoft Mail, Banyan Vines, Hewlett-Packard OpenMail, or whatever. In practice, CMC is very rarely used due to lack of support; should you come across it anywhere, you will at least now know what it is.
In the first quarter of 1996, Microsoft released Exchange Server 4.0 - the first version of Exchange Server, despite the numbering. This replaced Microsoft Mail Post Office with a more flexible, more powerful server. With the release of Exchange Server 4.0 came a new mail API, Extended MAPI 1.0. The 'official' name for this is simply MAPI 1.0, but to keep things clear, it is still referred to as Extended MAPI from time to time, in order to retain the distinction between this and Simple MAPI.
Extended MAN is the underlying system on top of which every Exchange-based mail system produced since 1996 runs.
This key fact means that using Extended MAPI in your applications does have its advantages write it once and it will work on any recent Microsoft mail system. But, naturally, it also has its downsides. Extended MAN is a complex API with a steep learning curve. To make matters worse, it doesn't support a dispatch interface, just a plain COM interface - this translates to meaning that it can only be used from C or C++, not Visual Basic/VBScript, and so on (although, with some wrestling, it can be used with Delphi).
If you need the features of Extended MAPI, nothing else will suffice. However, CDO is much simpler to work with for the vast majority of tasks you will need to perform. It is also possible to write "hybrid" code in your apps that uses CDO for most of the work and also Extended MAPI when absolutely necessary; this is covered in more detail in Chapter 14.
However, by the time Extended MAPI was released, the Visual Basic community had become large enough that it was obvious that some way was needed to allow those programmers to access the new, more powerful features beyond the basic ones available in Simple MAPI. The library written to allow that is what we now know as CDO-though, as we'll see, it has had various names over the years.
Extended MAPI is a very low-level interface; you can talk to the objects stored on the Exchange Server directly, with no wrappers to interfere with your code. This makes it the most powerful way to write Exchange Server-enabled applications, because there are no restrictions on what you can do.
Early Versions of CDO
With the release of Microsoft Windows Messaging with Microsoft Windows 95 and Microsoft Windows NT 4.0, and later Exchange Client 4.0, Microsoft released a new library called OLE Messaging 1.0.
The OLE in OLE Messaging stands for "Object Linking and Embedding", and was the general term used at the time for the architecture that would later become COM. In this context, "OLE Messaging" simply means a messaging system that uses the standard OLE interfaces to access it. At the time, OLE was one of the technologies that Visual Basic used to communicate with external components, and so this was the first non-trivial (not Simple MAPI) messaging library for Visual Basic users.
After the success of Microsoft Exchange Server 4.0, Microsoft recognized the need to provide greater functionality and programmability to their customers, releasing Microsoft Exchange Server 5.0 in the first quarter of 1997. This version of Exchange Server introduced a great deal of new Internet features (like the first version of Outlook Web Access, called "Exchange Active Server Components"). It also brought with it a new version (1.1) of the OLE Messaging Library, which was renamed to Active Messaging,
Where CDO Is Now
With the release of Microsoft Exchange Server 5.5 in the last quarter of 1997, Microsoft again responded to developers crying for a technology with more power and functionality that was afforded them in the Active Messaging 1.1 Library. They had seen that capabilities far beyond simple messaging were needed, stretching into the areas of calendaring, collaboration, and workflow. Outlook had provided these in one way or another for a long time (longer still if you count Schedule+), but there had not previously been a way for programmers to take advantage of these features. In response, Microsoft replaced the Active Messaging 1.1 Object Library with the Collaboration Data Objects 1.2 Object Library.
The current version of CDO is actually version 1.21, which shipped as the first release of CDO with a client, namely Outlook 98 - this fixes some bugs in CDO 1.2. As such, if we refer to CDO 1.2, this can also be taken to mean CDO 1.21.
To add to the confusion, there is more than one version of CDO 1.2 1; Exchange Server Service Packs tend to contain even newer versions. The definitive latest version is the one you can download from Microsoft, though, at
As a final summary to the history of CDO, we'll look in slightly more detail at how CDO and MAPI interact-for now, we're still only talking about 'pure' CDO. As we'll see, there are a few libraries that have a claim to the name.
Versions of MAN and Where to Get Them
Since CDO in all its versions uses MAPI as the underlying messaging system to talk to Exchange Server, you must have the MAPI messaging system installed to use CDO's features. This is important for application developers who want to use CDO to build stand-alone applications that need access to an Exchange Server-based mailbox.
While you can download the CDO for Exchange DLL from the Microsoft web site, this does not contain the underlying MAPI system that CDO needs to talk to Exchange. It's not possible to simply distribute MAPI32.DLL, either - Microsoft's license forbids it, for one thing, and for another even if you did try this it wouldn't work because there are registry settings required which only come with a proper installation of MAPI.
There is a version of the Windows Messaging System available for download from Microsoft's web site - however, that version is very old and Microsoft do not recommend using this with CDO. Similarly, Exchange Client 5.0 (the precursor to Outlook 97) comes with a MAPI system, but that is also sufficiently old that there's no guarantee it won't fail.
Essentially, you will have to install Outlook 97, 98, or 2000. You can try using earlier versions or the freely distributable MAPI subsystem, but those are unsupported, and you may well hit mysterious problems. We don't recommend you do this, and this book is written assuming you have installed a version of Outlook to get your MAPI subsystem.
Note that if you have Outlook 98 or Outlook 2000 installed, you have to make sure you have them installed in Corporate or Workgroup Mode, as opposed to Internet Mail Only Mode.
Beginning with Outlook 98, Microsoft developed two different versions of the Outlook client. The CW or "Corporate or Workgroup Mode", version is dedicated to work with Microsoft Exchange Server (5.0 and upwards) because it is the MAPI-based version of Outlook 98/2000. This is also the version you need to install if you want to connect to a Microsoft Mail postbox-based server, or to Novell Groupwise, and so on; it is basically the "full" version of Outlook.
The IMO, or Internet Mail Only Mode, version is dedicated to work with Mail servers which support the Internet standards for messaging and directory access, like POP3, IMAP4, and LDAP. It does not provide any MAPI subsystem and therefore can't access an Exchange Server-based mailbox. Note that you can still mail Internet users using Outlook in CW mode, as long as your Exchange Server is set up to talk to the Internet - the restriction is that you can't talk to nonInternet users in IMO mode. Of course, if your Exchange Server is set up to support Internet mail standards, you can talk to it using Outlook in IMO mode, though at this point you would probably be better off using CW mode...