Microsoft KB Archive/171096

= Simple MAPI console application =

Article ID: 171096

Article Last Modified on 8/18/2005

-

APPLIES TO


 * Simple Messaging Application Programming Interface (MAPI)

-



This article was previously published under Q171096



SUMMARY
This is a Simple MAPI console application that demonstrates how to use most of the Simple MAPI functions available. It is written in Microsoft Visual C++ 5.0 but any previous version of the compiler works just as well.

The following file is available for download from the Microsoft Download Center:

Download Smplmapi.exe now

The Smplmapi.exe file contains the following files:

SwapMain.cpp

SwapMain.h

Swap.cpp

Swap.h

Swap.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.



MORE INFORMATION
SwapMain.cpp is the main controlling program file. It is responsible for displaying a menu to the user and interpreting the commands given by the user. The code in this file is written specifically for a console application, but because it makes calls into a separate module that implements functionality using a user-defined class, a windows style application could be easily substituted as the main controller of the application.

Swap.cpp is the implementation of an application class that provides the basic functionality required by the menu presented in the main control module.

This messaging application is a Simple MAPI client. It implements the following features:


 * Present the user with a menu
 * Logon to messaging system
 * Select a recipient/Get e-mail address
 * Enter e-mail address/Get recipient
 * Get details of recipient
 * Send mail message to recipient using default UI
 * Send mail message to recipient with no user interface
 * Send mail message with an attachment
 * Create a new message
 * List messages in the Inbox
 * Read next unread message
 * Log off of the messaging system
 * Exit the client
 * Refresh the menu

The following features are not discussed in this document because the code to implement them is trivial and not related to MAPI at all:


 * Present the user with a menu
 * Exit the client
 * Refresh the menu

Logon to Messaging System
The user is prompted for a profile name. If it can find the profile name in the list of profiles, it will log the user on to the messaging system. If it cannot find the profile entered by the user in the list of profiles, the user is to cancel the operation or choose from an existing list.

Select a Recipient/Get E-Mail Address
The user is prompted with an address book list. When an entry is chosen from this list, the method allocates a buffer and stuffs the buffer with the e-mail address of the recipient chosen in the list. The buffer must be released by the caller of this method.

Enter E-Mail Address/Get Recipient
The user is prompted to type an e-mail address. When a valid e-mail name is entered and found in the address book, the method allocates storage for a buffer and stuffs the buffer with the display name of the e-mail alias. The buffer allocated in this method must be released by the caller.

Get Details of Recipient
The user is prompted to type an e-mail address. When a valid e-mail address is entered and found in the address book, the user is presented a "details" page filled with information specific to the e-mail address entered by the user.

Send Mail Message to Recipient Using Default UI
The user is prompted with the default "Compose Note" form. When the message has been given a recipient to send to and the send button is pressed, the intended recipient gets the message.

Send Mail Message to Recipient with No User Interface
The user is prompted for the intended recipient. After a valid recipient is entered, a hard-coded message is sent to the intended recipient.

Send Mail Message with an Attachment
The user is prompted for the intended recipient. After a valid recipient is entered, the user is prompted for the file and path of a file to attach. The file name must be the 8.3 representation of the file to attach. The path name must be in the following format: "c:\windows\" (Note: the trailing backspace is mandatory). A message is then sent to the intended recipient.

Create a New Message
A new message is automatically created in the Inbox of the user's default message store.

List Messages in the Inbox
The user is presented with a list of the messages in the user's default message store Inbox.

Read Next Unread Message
The user is presented with the contents of the next unread message in the default message store Inbox.

Log Off of the Messaging System
The session handle is released and the user is logged off of the messaging system. No MAPI specific menu options are available until the user requests to be logged back on to the messaging system. The application remains running until the user chooses to exit the application. If the user elects to exit the application without first logging off, the session is terminated in an orderly fashion and then the application closes.

Keywords: kbhowto kbgraphxlinkcritical kbsmapicmc kbmsg kbfile kbsample KB171096

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.