FILE: Simple MAPI Console Application

Last reviewed: October 10, 1997
Article ID: Q171096
The information in this article applies to:
  • Simple Messaging Application Programming Interface (MAPI), version 1.0

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 Software Library:

 ~ Smplmapi.exe (size: 57431 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

MORE INFORMATION

This self-extracting executable file contains the following files:

SwapMain.cpp SwapMain.h Swap.cpp Swap.h Swap.exe

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          : kbsample SMapiCMC
Version           : WINDOWS:1.0
Platform          : WINDOWS
Issue type        : kbhowto
Solution Type     : kbfile


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.