The information in this article applies to:
- Collaboration Data Objects (CDO), versions 1.1, 1.2
SUMMARY
Collaboration Data Objects (formerly known as Active Messaging) provides a
means for sending, receiving, and processing messages programmatically.
While most of the documentation provides sample code for Visual Basic, some
people prefer to create C/C++ applications to perform the same tasks.
This article contains two code samples. The samples are an illustration and
give developers a starting point in writing Collaboration Data Objects
(CDO) applications in C/C++.
MORE INFORMATION
The following files are available for download from the Microsoft Software
Library:
~ Mfccdo.exe (size: 3755397 bytes)
~ Sampcdo.exe (size: 2288408 bytes)
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591
TITLE : How to Obtain Microsoft Support Files from Online Services
README.1ST (for Mfccdo.exe)
CDOMFC Sample Application
This project was generated and built on the use of Collaboration Data
Objects (CDO) (formerly known as Active Messaging) version 1.1. However,
the functionality that is illustrated in this application is backwards-
compatible with 1.0 (except for creating of MAPI.Session) and forward-
compatible with version 1.2 that is now available with Microsoft Exchange
Server 5.5.
Purpose
This application provides a working sample for troubleshooting problems
when calling the CDO library with the Microsoft Foundation Classes (MFC)
COleDispatchDriver class.
Application Files
The following files are included with this sample:
- Cdomfc.dsw: Microsoft Visual C++ 5.0 Workspace.
- Cdomfc.dsp: Microsoft Visual C++ 5.0 Project File.
- Cdomfc.cpp: Defines the class behaviors for the application.
- Cdomfc.rc: Dialog, icon, and version resources for the application.
- Cdomfcdlg.cpp: Implementation for the dialog class of the application.
- Olemsg32.cpp: Originally generated by the ClassWizard; modified by
the author for easier use of methods and classes and provides
implementation for classes defined in Olemsg32.h.
- Stdafx.cpp: Standard includes for the application.
- Cdomfc.h: Main header file for the application.
- Cdomfcdlg.h: Header file for the dialog class of the application.
- Olemsg32.h: Originally generated by ClassWizard; modified by the
author for easier use of methods and classes.
- Resource.h: Automatically generated by DevStudio; used by Cdomfc.rc.
- Stdafx.h: Include file for standard system files.
- Res\cdomfc.ico: Generic icon for the application.
- Res\cdomfc.rc2: Manually edited resources for the application.
- Readme.txt: Automatically generated by MFC AppWizard.
- Readme2.txt: This file contains general information about the sample.
- Debug\cdomfc.exe: Debug build of the application.
- Release\cdomfc.exe: Release build of the application.
CDO Functionality Illustrated
The following tasks are illustrated by this application:
- Create MAPI.Session.
- Logon with prompt for profile.
- Logon with specified profile.
- Create a new message.
- Add and resolve recipients selected from the AddressBook.
- Add and resolve specified recipients.
- Attach a specified file to the message.
- Send the message without displaying the message form.
- Send the message by displaying the message form first.
- Logoff the session.
Although there is a tremendous amount of functionality that is not
illustrated in this basic sample, the basics for calling any of the
methods, modifying the generated classes, and getting/setting properties
can be applied to all other areas of the CDO library.
Modification of ClassWizard-Generated Files
The Olemsg32.h and Olemsg32.cpp files were generated by the ClassWizard
from the Olemsg32.dll library. These files were then modified in the
following ways:
- Allows for calling methods with fewer or no parameters. For example,
Session->Logon() was overridden to allow for no or one parameter rather
than requiring all seven of the possible parameters.
- Allows for a specific return value type, rather than the generic VARIANT
data type. For example, the Message->GetAttachments() method was
modified to return an Attachments collection rather than a VARIANT.
Some classes not used by this sample were also modified and methods
overridden to provide a starting point for re-use.
Readme.txt (for Sampcdo.exe)
CDOSAMP Sample Application
This project was created and built on the use of Collaboration Data Objects
(CDO) (formerly known as Active Messaging) version 1.1. However, the
functionality that is illustrated in this application is backwards-
compatible with 1.0 (except for creating of MAPI.Session) and forward-
compatible with version 1.2 that is now available with Microsoft Exchange
Server 5.5.
Purpose
This application provides a working sample for troubleshooting problems
when calling the CDO library directly with InvokeHelper, GetProperty, and
SetProperty. This sample is implemented as a Console application in order
to keep it as simple as possible.
Application Files
The following files are included with this sample:
- Cdosamp.dsw: Microsoft Visual C++ 5.0 Workspace.
- Cdosamp.dsp: Microsoft Visual C++ 5.0 Project File.
- Main.cpp: Main code file containing the menu and related functions.
- Utility.cpp: File containing the custom Invoke and Get/SetProperty
helper functions.
- Cdosamp.h: Main header file for the application.
- Readme.txt: Automatically generated by MFC AppWizard.
- Debug\Cdosamp.exe: Debug build of the application.
- Release\Cdosamp.exe: Release build of the application.
CDO Functionality Illustrated
The following tasks are illustrated by this application:
- Create MAPI.Session.
- Logon with prompt for profile.
- Logon with specified profile; the code could be modified to
change the specified profile or to allow the user to enter a
profile name.
- Create a new message.
- Add, resolve, and list recipients selected from the AddressBook
- Add, resolve specified recipients; the code could be modified to
change the specified recipients or to allow the user to enter a
list of recipients.
- Attach a specified file to the message; the code could be
modified to change the specified file or to allow the user to
enter a file name.
- Send the message without displaying the message form.
- Send the message by displaying the message form first.
- Logoff the session.
- Delete the session.
Although there is a tremendous amount of functionality that is not
illustrated in this basic sample, the basics for calling any of the methods
and getting/setting properties can be applied to all other areas of the CDO
library.