The IMAPIFolder::CopyMessages method copies or moves one or more messages.
See IMAPIFolder : IMAPIContainer.
HRESULT CopyMessages(
LPENTRYLIST lpMsgList,
LPCIID lpInterface,
LPVOID lpDestFolder,
ULONG ulUIParam,
LPMAPIPROGRESS lpProgress,
ULONG ulFlags
);
The IMAPIFolder::CopyMessages method copies or moves messages to another folder.
Messages that are open with read/write access can be moved or copied.
If you are copying messages to another message store without using the IMAPISupport::CopyMessages method, you must first call IMAPIFolder::SetReadFlags with the GENERATE_RECEIPT_ONLY flag set. The receiving message store is not responsible for generating read reports for the copied or moved messages. If you are calling IMAPISupport::CopyMessages to implement IMAPIFolder::CopyMessages, do not make the SetReadFlags call. MAPI will take care of it.
Move or copy the messages in any order and generate read status reports in any order. That is, you can finish copying messages before generating any of the read status reports or send the reports before beginning the copy. However, read reports should be sent for all messages to be copied, regardless of whether or not the copy is successful.
When the copy or move operation involves more than one message, perform the operation as completely as possible. Do not stop the operation prematurely unless a failure occurs that is beyond your control, such as running out of memory, running out of disk space, or corruption in the message store.
Try to maintain entry identifiers across move or copy operations.
Send notifications when moving or copying messages so that clients are forewarned that their calls to the messages' IMAPIProp::SaveChanges methods may fail.
Do not include a message's status in the copy or move operation. Moving or copying a message status greatly affects performance.
Use CopyMessages for populating search-results folders, where messages are often grouped by parent folder.
Expect these return values under the following conditions:
Condition | Return value |
---|---|
CopyMessages has successfully copied or moved every message. | S_OK |
CopyMessages was unable to successfully copy or move every message. | MAPI_W_PARTIAL_COMPLETION |
CopyMessages was unable to complete. | Any error value |
When CopyMessages is unable to complete, do not assume that no work was done. CopyMessages might have been able to copy or move one or more messages before encountering the error.