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
-
Create a MapiMessage structure to contain the message.
-
Create one or more MapiRecipDesc structures describing the recipients of the message and place them in the lpRecips member of the MapiMessage structure.
-
Create a text string containing the subject, if any, and place it in the lpszSubject member of the MapiMessage structure.
-
Create a text string containing the message text, if any, and place it in the lpszNoteText member of the MapiMessage structure.
-
Create an array of MapiFileDesc structures, if necessary, to contain any attachments and place it in the lpFiles member of the MapiMessage structure.
-
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
-
Allocate a MapiMessage structure.
-
Fill in the MapiMessage structure members with values appropriate for the message the user wants to send.
-
Submit the MapiMessage structure to the messaging system by calling the MAPISendMail function.
To forward an existing message
-
Retrieve the message by calling the MAPIReadMail function.
-
Modify the message as appropriate for forwarding:
-
Put one or more new recipients' addresses in the message's lpRecips member.
-
Modify the subject line to indicate that the message has been forwarded.
-
Allow the user to edit the message text.
-
Submit it to the messaging system by calling the MAPISendMail function.
To reply to a message
-
Retrieve the message by calling the MAPIReadMail function.
-
Modify the message as appropriate for replying:
-
Put the original sender's address into the lpRecips member.
-
Change the subject line to indicate that the message is a reply to an earlier message.
-
Allow the user to edit the message text.
-
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;