The IMAPISupport::CopyFolder method copies or moves a folder from its current parent folder to another parent folder.
HRESULT CopyFolder(
LPCIID lpSrcInterface,
LPVOID lpSrcFolder,
ULONG cbEntryID,
LPENTRYID lpEntryID,
LPCIID lpInterface,
LPVOID lpDestFolder,
LPSTR lpszNewFolderName,
ULONG ulUIParam,
LPMAPIPROGRESS lpProgress,
ULONG ulFlags
);
All of the folder's subfolders should be copied or moved. When COPY_SUBFOLDERS is not set for a copy operation, only the folder identified by lpEntryID is copied. With a move operation, the COPY_SUBFOLDERS behavior is the default regardless of whether the flag is set.
The name of the folder being moved or copied is the same as that of a subfolder in the destination folder. The message store provider requires that folder names be unique. The operation stops without completing.
The call succeeded, but not all entries were successfully copied. When this warning is returned, the call should be handled as successful. To test for this warning, use the HR_FAILED macro. See Using Macros for Error Handling.
The IMAPISupport::CopyFolder method is implemented for message store provider support objects. Message store providers can call CopyFolder in their implementation of IMAPIFolder::CopyFolder to copy or move a single folder from one parent folder to another.
CopyFolder adds the copied or moved folder as a subfolder of the destination folder.
CopyFolder allows simultaneous renaming and moving of folders and the copying or moving of subfolders of the affected folder. To copy or move all subfolders nested within the copied or moved folder, pass the COPY_SUBFOLDERS flag in ulFlags.
Expect these return values under the following conditions:
Condition | Return value |
---|---|
CopyFolder has successfully copied or moved the folder and all of its subfolders, if applicable. | S_OK |
CopyFolder was unable to successfully copy or move all of the folders. | MAPI_W_PARTIAL_COMPLETION |
CopyFolder was unable to complete. | Any error value |
If CopyFolder returns an error value, do not proceed on the assumption that no work was done. One or more folders could have been copied or moved before CopyFolder experienced the failure.