In case you haven't noticed, the computing world is getting wired. You can connect computers to each other in ways never before thought possible. Electronic messaging is creating an explosion of information that even computers have trouble sorting through. This presents a problem for developers. There are as many different ways to program and access electronic messaging systems as there are electronic messaging systems. What's a developer to do? Enter messaging application program interface (MAPI).
MAPI is a messaging middleware standard developed by Microsoft with the help of other software vendors, consultants, and users. Like Open Database Connectivity (ODBC), MAPI is a set of application program interfaces (APIs) that sits between client software and server software. Designed to make life easier for developers and users, MAPI provides a way to utilize disparate messaging systems without having to learn each individual system, and it supports independent front- and back-end systems. With MAPI, developers can write a single application that works simultaneously with multiple messaging systems such as IBM OfficeVision, Microsoft Mail, and Novell MHS.
MAPI and E-mail
Using MAPI, you can do some interesting things with E-mail. For example, you can create a program to filter out unwanted messages from your in-box or an electronic form on which users report program problems. You can tie a MAPI program to the AS/400 to send E-mail to the appropriate person when system problems occur. Using the new V3R1 features of DB2/400, you can add a trigger to your inventory file to send E-mail to the purchasing department or even the vendor when stock levels reach a certain point. The world of electronic messaging brings out many exciting possibilities.
Most E-mail systems have four primary components: client software, message store, transport provider, and directory services. The mail client software provides the user interface for the E-mail system. The message store is where the mail is gathered for delivery to the recipient, even if the recipient is offline when the message is sent. The transport provider ships the messages, and directory services determine where and to whom a message is to be delivered. MAPI provides a common interface between these components, even if they are from different vendors.
MAPI supplies the functionality and, optionally, the user interface for mail-enabled and mail-reliant programs. Mail-enabled programs will use an E-mail system if one is available, but their primary functionality does not require a messaging system. A word processor with a "send mail" menu item is an example of a mail-enabled program. Mail-reliant applications require electronic messaging to communicate with the outside world. An example of this type of program is a groupware scheduler. Developers can also use MAPI for program-to-program communications.
1 shows the architecture of a MAPI system. MAPI is really two sets of APIs. One set provides an interface between the mail client software and the front-end to the messaging system. Lotus cc:Mail and Microsoft Exchange have mail clients. These client programs don't actually deliver the mail, but serve as an interface to the mail back-ends. The other API set provides the interface to the back-end mailing system. It simplifies life for back-end mail system developers because they can write to a single API set that provides functionality for many client front-ends. (The back-end APIs are what allow IBM to provide MAPI support in Client Access for Windows.) It simplifies life for front-end developers because they can employ a single API set to interface to many back-end systems.
Figure 1 shows the architecture of a MAPI system. MAPI is really two sets of APIs. One set provides an interface between the mail client software and the front-end to the messaging system. Lotus cc:Mail and Microsoft Exchange have mail clients. These client programs don't actually deliver the mail, but serve as an interface to the mail back-ends. The other API set provides the interface to the back-end mailing system. It simplifies life for back-end mail system developers because they can write to a single API set that provides functionality for many client front-ends. (The back-end APIs are what allow IBM to provide MAPI support in Client Access for Windows.) It simplifies life for front-end developers because they can employ a single API set to interface to many back-end systems.
Choose Your MAPI
MAPI comes in a few different flavors that address the varying needs of developers. The most common in the Windows environment is Simple MAPI. It consists of a few high-level APIs for creating, addressing, and receiving mail. These APIs are listed in 2. Simple MAPI provides optional common dialogs that can be used to present a consistent, familiar interface to the user. It also provides support for file attachments and name resolution. File attachments allow one or more files to be attached to a message, providing a convenient means of exchanging information. Name resolution is useful when users don't know the exact spelling of an addressee's name; it displays a dialog box that allows the user to search based on partial names.
MAPI comes in a few different flavors that address the varying needs of developers. The most common in the Windows environment is Simple MAPI. It consists of a few high-level APIs for creating, addressing, and receiving mail. These APIs are listed in Figure 2. Simple MAPI provides optional common dialogs that can be used to present a consistent, familiar interface to the user. It also provides support for file attachments and name resolution. File attachments allow one or more files to be attached to a message, providing a convenient means of exchanging information. Name resolution is useful when users don't know the exact spelling of an addressee's name; it displays a dialog box that allows the user to search based on partial names.
Another popular mail exchange standard supported by MAPI is the Common Messaging Call (CMC) format. The CMC format is useful for cross-platform mail development, as it is supported by many vendors on OS/2, DOS, Windows, UNIX, and Macintosh platforms. The 10 APIs of the CMC API set map easily to the Simple MAPI APIs, so it shouldn't be too much work to switch between the two.
Extended MAPI is a superset of Simple MAPI that provides hooks for advanced addressing, high-volume messaging, and electronic forms. Electronic forms replace the standard mail interface with a specific form designed for a specific type of message. Using Extended MAPI, you could develop an electronic phone message form that looks like the paper phone message forms you are using but delivers messages to your electronic in-box. It also provides support for routed forms. You could create a purchase order form using Extended MAPI and route it to the appropriate people for denial (or perhaps approval). Extended MAPI's support for address books allows you to group potential addressees in an organized manner.
While not all mail systems speak MAPI, more and more are adopting it as an interface option. For those systems that have it, MAPI presents a welcome change for the developer who used to have to address each E-mail system separately. By providing a single interface for development, MAPI enhances the communication capabilities of many applications. In a future article, we will explain, step by step, how to create a MAPI program. In the meantime, you can find out more about MAPI from Microsoft's MAPI SDK or from numerous third-party books.
Brian Singleton is an associate technical editor for Midrange Computing.
Get Wired with MAPI
Figure 1: MAPI System Architecture
Get Wired with MAPI
Figure 2: Simple MAPI APIs
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. 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 using a dialog box. MAPISendMail Sends a mail message, allowing greater flexibility in message generation than MAPISendDocuments.
LATEST COMMENTS
MC Press Online