Platform SDK: Exchange Server |
When creating a new message, some message properties are required and others are optional. For example, it is important that you set the PR_MESSAGE_CLASS property of the message. See step 3 of the following procedure.
For a list of message properties that are automatically set, see Properties Set at Message Creation.
To create a message
The following sample code illustrates these steps:
// Create new message with MAPI call... hr = lpNewFolder->CreateMessage( NULL, // Interface ID, must be NULL for client apps MAPI_DEFERRED_ERRORS, &lpNewMessage); // Set appropriate message properties. Here's a list of the most common... // PR_SENDER_NAME, // PR_SENDER_ENTRYID, // PR_SENDER_ADDRTYPE, // PR_SENDER_EMAIL_ADDRESS, // PR_SENT_REPRESENTING_NAME, // PR_SENT_REPRESENTING_ENTRYID, // PR_SENT_REPRESENTING_ADDRTYPE, // PR_SENT_REPRESENTING_EMAIL_ADDRESS, // PR_CLIENT_SUBMIT_TIME, // PR_MESSAGE_DELIVERY_TIME, // PR_IMPORTANCE, // PR_EXPIRY_TIME, // PR_MESSAGE_ATTACHMENTS, // PR_RTF_COMPRESSED or PR_BODY // PR_SUBJECT // PR_MESSAGE_CLASS // SaveChanges commits the current state of the message. // Must use KEEP_OPEN_READWRITE or KEEP_OPEN_READONLY if you // intend to access the message later. hr = lpNewMessage->SaveChanges( KEEP_OPEN_READWRITE );
Note The maximum number of messages that a folder in a personal folder store (PST) can hold is 16,383. Once this number has been reached, an attempt to create another message in the folder results in the error MAPI_E_TABLE_TOO_BIG being returned by the call to the IMAPIProp::SaveChanges method.