Programming MicrosoftВ® OutlookВ® and Microsoft Exchange 2003, Third Edition (Pro-Developer)
CDO is an object library that exposes the interfaces of the Messaging Application Programming Interface (MAPI), but instead of requiring the C/C++ language as MAPI does, CDO can be programmed using any development tool that can reference COM objects, such as ASP, Visual Basic, Microsoft Visual C#, or Microsoft Visual C++.
CDO has had several incarnations; previous versions shipped with different names and functionality. For example, in Microsoft Exchange Server 4.0, CDO was named OLE Messaging, and in Exchange Server 5.0, it was named Active Messaging. With the advent of Exchange Server 5.5 and Microsoft Outlook 98, the library was renamed Collaboration Data Objects to better describe its services ”CDO provides much more than messaging functionality. Even though the name has changed from version to version, CDO is backward compatible with applications that use a previous version of the object library. (As of this writing, the latest released versions of CDO are CDO for Microsoft Windows, CDO 1.21, and CDO for Exchange.)
CDO is actually divided into four dynamic link libraries (DLLs): CDO.dll and CDOHTML.dll for CDO 1.21, and CDOEX.dll and CDOEXM.dll for CDO for Exchange. We'll cover CDO 1.21 in this chapter and then look at CDO for Exchange in Chapters 15 and 18. CDO.dll contains the core collaborative functionality of CDO, such as functionality for sending messages, accessing the directory, and viewing free/busy calendar information. CDOHTML.dll is the CDO Rendering library. This library allows you to automatically convert information stored in Exchange Server to HTML by using custom views, colors, and formats. The CDO Rendering library is installed when you install OWA on your Web server. Throughout this chapter, you will learn how to use both CDO 1.21 libraries in your applications.
Note | You install CDO by installing Outlook on your machine or by installing Outlook Web Access (OWA) version 5.5 on your Web server. When you install CDO via Outlook, you do not get the CDO Rendering library. If you are using CDO 1.21 with Exchange 2000 or later, the CDO Rendering library will still work, but you should consider using some of the newer technologies included with Exchange, such as WSS Forms. Also, if you will be using CDO on your Web server and your Exchange Server is on a different server, you can get CDO by installing Exchange 5.5 OWA, Exchange 2000/2003 Server, or the Exchange administration program in Exchange 2003. Installing the Exchange administration program for Exchange 2000 does not install CDO, but Exchange 2003 does. Also, you should not install a secure version of CDO, such as the CDO that comes with Outlook, on the server because any Outlook security prompts will not work in a non-UI environment such as server-side code in ASP or ASP.NET. If you find that you are getting logon or unexplained errors using CDO, make sure you do not have a secure version of CDO on the machine by checking to see if Outlook is on the machine. |
CDO and the Outlook Object Library
CDO and the Outlook object library are complementary technologies. The Account Tracking application discussed in Chapter 8 illustrates how to use the CDO library in conjunction with the Outlook object library. You might be wondering when to use each library. To make a decision, you should consider security criteria such as where the application will run and what type of information it will access. As you develop applications, you will find that deciding between the Outlook library and the CDO library will almost never be simple. You can use the Outlook object library to do the following:
-
Access special information stored in Outlook, such as Tasks and Journal items, that CDO does not support
-
Open another user 's information, such as the Calendar or Inbox
-
Sort or filter complex Outlook properties
You can use the CDO library to do the following:
-
Render objects or data into HTML
-
Create multiuser server-based applications
-
Access detailed information stored in the directory or display address books for users to pick from
CDO and CDO for Windows
When you install Microsoft Internet Information Services (IIS), you have the option to install a Simple Mail Transfer Protocol (SMTP) component and a Network News Transfer Protocol (NNTP) component on your Web server. These components are subsets , functionally, of the CDO library named Collaboration Data Objects for Windows (CDOSYS). The CDO for Windows library allows you to quickly build applications that do not require the complete functionality of CDO. For example, if on your web page you want to create a simple way for users to send comments through e-mail, you should use the CDO for Windows object library rather than CDO. If your application requires looking up a user in a directory server, however, you should use the advanced functionality of the full CDO library. Another difference between CDO and CDO for Windows is that CDO for Windows uses only SMTP and NNTP to communicate with a server. The use of these protocols to talk with the server limits the functionality that CDO for Windows library can provide. With that said, you should use the CDO for Windows library to do the following:
-
Send unauthenticated e-mail from a Web page
-
Send bulk mailings via e-mail
-
Support Mime HTML (MHTML)
You should use the CDO 1.21 library to do the following:
-
Use authenticated or anonymous access to information, but not anonymous e- mails
-
Access or create calendaring information
-
Access a directory and its information
Which CDO Should I Use Where?
With all the versions of CDO, you might get confused about which CDO you can use where and which version to use with which version of Exchange Server or Outlook. Table 11-1 can help you decide.
Application Usage | Outlook Object Model | CDO 1.21s (secure version installed via Outlook) | CDO 1.21 (server version via Exchange Server or OWA) | CDO for Exchange 2000 |
---|---|---|---|---|
Client-Side Application (Outlook form, Visual Basic application) | Yes | Yes | Yes | No (not remotable) |
Web Server Application | No | No (security dialog boxes cause problems in Web applications) | Yes | Yes (if Web server is on same server as Exchange 2003) |
Windows Service | No | No (security dialog box problems) | Yes | Yes |
Access Exchange 5.5 Data | Yes | Yes | Yes | No |
Access Exchange 2003 Data | Yes | Yes | Yes | Yes |