Platform SDK: Exchange Server

Sending a Message

When submitting a new message, the list of recipients must contain at least one entry. This is accomplished in steps 2 and 3.

To send a message

  1. Create the message to be sent. See Creating a Message.
  2. Using the HrMAPICreateAddressList function, create and set the values of a recipient list, which is an LPADRLIST structure. This list contains all the TO, CC, and BCC recipients of the message.
  3. Modify the recipient list of the message by calling the MAPI IMessage::ModifyRecipients method.
  4. Optionally, set the PR_MESSAGE_CLASS and PR_DELETE_AFTER_SUBMIT properties.
  5. Submit the message by calling the IMessage::Submit method.

The following sets addressing information on an existing message, and submits it:

// These calls create and set information in the address list data structure.
hr = HrMAPICreateAddressList( cProps, lpAdrProps, &lpAdrList);

// If you copy address information from another message, these
    properties have the same values:    
// New address property         was Property in message
// PR_DISPLAY_NAME was     PR_SENDER_NAME
// PR_ENTRYID     was PR_SENDER_ENTRYID
// PR_ADDRTYPE was PR_SENDER_ADDRTYPE
// PR_EMAIL_ADDRESS was     PR_SENDER_EMAIL_ADDRESS
//
// Also, the recipient's PR_RECIPIENT_TYPE must be MAPI_TO, MAPI_CC, or MAPI_BCC

// Update the message with list of addressees.
hr = lpNewMessage->ModifyRecipients( 0L, lpAdrList);

hr = HrMAPISetPropBoolean( lpNewMessage, PR_DELETE_AFTER_SUBMIT, TRUE);

// Last step: submit the message.
hr = lpNewMessage->Submit( 0L);