Sending Messages with Simple MAPI

To compose a message, a client application either creates a new message, forwards an existing message, or replies to an existing message. The new message can contain new material. Replying to existing messages involves creating a new message and copying the contents of the original message to it. All new messages can specify a return receipt as well.

    To send a message
  1. Create a MapiMessage structure to contain the message.
  2. Create one or more MapiRecipDesc structures describing the recipients of the message and place them in the lpRecips member of the MapiMessage structure.
  3. Create a text string containing the subject, if any, and place it in the lpszSubject member of the MapiMessage structure.
  4. Create a text string containing the message text, if any, and place it in the lpszNoteText member of the MapiMessage structure.
  5. Create an array of MapiFileDesc structures, if necessary, to contain any attachments and place it in the lpFiles member of the MapiMessage structure.
  6. Submit the message by calling the MAPISendMail function.

Sending messages can involve more or less effort on the part of your client, depending on the way you invoke various Simple MAPI functions to perform the above steps. For more information, see Controlled Sending of a Message: Simple MAPI Sample.

    To create a new message
  1. Allocate a MapiMessage structure.
  2. Fill in the MapiMessage structure members with values appropriate for the message the user wants to send.
  3. Submit the MapiMessage structure to the messaging system by calling the MAPISendMail function.
    To forward an existing message
  1. Retrieve the message by calling the MAPIReadMail function.
  2. Modify the message as appropriate for forwarding:
  3. Submit it to the messaging system by calling the MAPISendMail function.
    To reply to a message
  1. Retrieve the message by calling the MAPIReadMail function.
  2. Modify the message as appropriate for replying:
  3. Submit the message to the MAPISendMail function.

When your client submits a message to MAPISendMail, it has the option of requesting a return receipt. Return receipts are automatically generated messages that senders receive to inform them that messages they sent, for which a return receipt was requested, were delivered successfully to the recipient. To request a return receipt, include the MAPI_RECEIPT_REQUESTED flag in the flFlags member of the MapiMessage structure:

// MapiMessage mymessage; declared and initialized elsewhere.
mymessage.flFlags |= MAPI_RECEIPT_REQUESTED;