Aisha Ikram is a senior software engineer and has been working mainly
in VC++ 6, MFC, ATL, COM. She now a days working on .NET framework and C#. She
is also a member of various developer's website like code project, code guru,
mind cracker and C# corner. You can write the author at
ais_ikr@yahoo.com
for your feedback concerns and problems.
Introduction
This article describes
differences between CDO (Active Messaging and OLE Messaging),
Simple MAPI, Common Messaging Calls (CMC), and Extended MAPI
(MAPI).
CDO
Collaboration Data Objects (CDO) or
"OLE/Active Messaging". CDO is a COM wrapper of the MAPI
library and can be called from any development language that
supports automation.
CDO implements most but not all MAPI
functionality, although far more than Simple MAPI. Followings
are some activities that can be accomplished using CDO:
- Log onto the messaging system with specific profiles or
with anonymous authentication.
- Compose messages, address and resolve recipients, send,
receive, and read messages, add attachments, automate
replies.
- Manage calendars; create meetings and appointments.
- Manage folders and messages within the information
store.
- Manage Addresses, especially within the Personal Address
Book (PAB).
There are two type of CDO
- MAPI based CDO.DLL
- SMTP (Simple
Mail Transfer Protocol) based CDONTS.dll.
This type allows rendering of selected information into HTML
format.
Note: CDO
usually comes with Exchange Server. The object library
consists of the in-process OLE servers called
Cdo.dll.
The Microsoft OLE Messaging Library exposes messaging
objects for use by tools supporting OLE automation, such as
those applications created in the Microsoft Visual Basic®
programming system and the Microsoft Visual C++® development
system applications. The messaging library lets you quickly
and easily add to your Visual Basic application the ability to
send and receive mail messages and to interact with folders
and address books. You can create programmable messaging
objects, then use their properties and methods to meet the
needs of your application. When you combine messaging objects
with other programmable objects exposed by Microsoft Access,
Microsoft Excel, and Microsoft Word, you can build custom
applications that, for example, would allow your users to
extract information from a database, copy it to a spreadsheet
for analysis, then create a report and mail the report to
several people. With these powerful building blocks, you can
quickly build custom applications that cover your entire
line-of-business needs. The Microsoft OLE Messaging Library
does not represent a new messaging model but rather an
additional interface to the Microsoft Messaging API (MAPI)
model.
Extended MAPI
The Messaging Application Program Interface (MAPI) is
set of functions that developers can use to create
mail-enabled applications. The full function library is known
as MAPI 1.0 or Extended MAPI. Extended MAPI allows complete
control over the messaging system on the client computer,
creation and management of messages, management of the client
mailbox, service providers.
Applications that use MAPI directly are written in C or
C++.
Simple MAPI
Simple MAPI is a of 12 functions, which support basic
messaging functionality for sending and receiving messages:
- Log onto the messaging system.
- Compose new messages, add and resolve recipients, send
messages.
- Retrieve and read messages from the inbox.
Followings are the functions included by SMAPI:
|
Function |
Description |
|
MapiAddress() |
Addresses a Mail message. |
|
MapiDeleteMail() |
Deletes a Mail message. |
|
MapiDetails() |
Displays a recipient details dialog box. |
|
MapiFindNext() |
Returns the ID of the next (or first) Mail message of
a specified type. |
|
MapiFreeBuffer() |
Frees memory allocated by the messaging
system. |
|
MapiLogoff() |
Ends a session with the messaging system. |
|
MapiLogon() |
Begins a session with the messaging system. |
|
MapiReadMail() |
Reads a Mail message. |
|
MapiResolveName() |
Displays a dialog box to resolve an ambiguous
recipient name. |
|
MapiSaveMail() |
Saves a Mail message. |
|
MapiSendDocuments() |
Sends a standard Mail message. |
|
MapiSendMail() |
Sends a Mail message. |
The Simple MAPI functions can be called from any
application that supports API calls and data structures and
types used by Simple MAPI, such as C, C++, Visual Basic/VBA.
The MAPI controls included with Microsoft Visual Basic
and the version of MAPI installed by Outlook Express implement
Simple MAPI only.
Recommendations:
It's recommended while writing a custom messaging
applications use either Collaboration Data Objects (CDO),
Extended MAPI, or Microsoft Outlook Object Model. All these
APIs ship with Microsoft Outlook clients except Microsoft
Outlook 98.
Limitations:
- Programmatic access to Microsoft Outlook Express client
is not supported. Simple MAPI is the only supported access
to Outlook Express messages.
- If you use CDO in an NT service with default client
Microsoft Outlook 97, it will generate error, However you
can use CDO with outlook 2000.
Messaging Client
Use MAPI for send and post OR use OLE/Messaging and/or
OLE/Scheduling
The Messaging Application Programming Interface (MAPI) is a
messaging architecture that enables multiple applications to
interact with multiple messaging systems seamlessly across a
variety of hardware platforms. The interfaces are used to
create and access diverse messaging applications and messaging
systems, offering a uniform yet separate environment for
development and use and providing true independence for both.
MAPI client applications are divided into three categories:
| Messaging-aware
applications
|
A messaging-aware application
does not require the services of a messaging system, but
includes messaging options as an additional feature. For
example, a word processing application can add a "Send"
command to its File menu, enabling the user to send a
document to another user. Example MS word, MS
Excel. |
| Messaging-enabled
applications
|
A messaging-enabled application
requires the services of a messaging system and
typically runs on a network or an on-line service. An
example of a messaging-enabled application is MS
outlook. |
| Messaging-based workgroup
applications
|
A more advanced client application is the
messaging-based workgroup, or workflow, application. The
workgroup application requires full access to a wide
range of messaging system services, including storage,
addressing, and transport services. These applications
are designed to operate over a network without users
having to manage the applications' network interaction.
Examples of such applications include work flow
automation programs and bulletin board services.
|
MAPI supports each of these
types of client applications by providing in its subsystem
different levels of programming interfaces. This multi-level
programming interface is described in the following section.
Conversion between the messaging environments
Most client applications will use one client API - either
OLE Messaging, Simple MAPI or Extended MAPI. However, some
clients will want to take advantage of what more than one
client API has to offer. These clients will want to use
Extended MAPI for some tasks and a simpler API for others. The
MAPI architecture allows client applications to do this fairly
easily by providing several API functions for converting
between the environments.
For instance to send a message you
need to do this:
- Create a
MapiMessage structure to contain the
message.
- Create one or more MapiRecipDesc
structures describing the recipients of the message.
- Create a text string containing the subject.
- Create a text string containing the message text.
- Create an array of MapiFileDesc
structures, if necessary, to contain any attachments.
- Submit the message with the
MAPISendMail function.
Posting messages and documents to folders (as
opposed to sending messages) is a common action performed by
client applications. For example, a client application may
post information to a public folder so that its associated
server application can read the information. To post
information, the application uses standard MAPI techniques and
follows this sequence shown below.
To post information to a
folder:
- Start a MAPI session.
- Open a public information store and obtain an
IMAPIFolder interface.
- Open a folder object within the public information
store.
- Create a message in the folder object. Upon creation,
the message exists in memory.
- Set relevant properties on the message.
- Use SaveChanges to save the message and its
properties to disk.
Adding
Your Mail Client to the File.Send Menu
You add your mail client to Send on the File
menu in applications that use simple or extended MAPI by doing
the following:
- Create the
HKEY_LOCAL_MACHINE\Software\Clients\Mail\MyMailClient
registry key.
- If your mail client supports the Microsoft Software
Installer (MSI), follow the instructions in Setting
Up the MSI Keys for Your MAPI DLL. Otherwise, proceed
with the following steps.
- Set the
HKEY_LOCAL_MACHINE\Software\Clients\Mail::(default)
value to identify your client's subkey; for example,
(REG_SZ) MyMailClient.
- Create the
HKEY_LOCAL_MACHINE\Software\Clients\Mail\MyMailClient::DLLPath
and set the value to (REG_SZ) c:\path\to\MyMAPI.dll, or
(REG_EXPAND_SZ) %ENVVAR%\MyMAPI.dll, where the path
identifies the DLL that exports simple MAPI functions. Note
that use of environmental variables in the path is
supported; the stub library performs the substitution when
resolving the path.
- If your mail client supports extended MAPI functions,
create the
HKEY_LOCAL_MACHINE\Software\Clients\Mail\MyMailClient::DLLPathEx
value and set the value to (REG_SZ)
c:\myinstall\MyMAPIex.dll, or (REG_EXPAND_SZ)
%ENVVAR%\MyMapi32.dll, where the path identifies the DLL
that exports extended MAPI functions. Note that use of
environmental variables in the path is supported; the stub
library performs the substitution when resolving the path.
Keep visiting the site for updated and new articles.
Sign my guest book OR send me your feedback at
ais_ikr@yahoo.com