Partager via


IMAPIFolder::DeleteMessages

Applies to: Office 2010 | Outlook 2010 | Visual Studio

In this article
Notes to Implementers
Notes to Callers
MFCMAPI Reference

Deletes one or more messages.

HRESULT DeleteMessages(
  LPENTRYLIST lpMsgList,
  ULONG_PTR ulUIParam,
  LPMAPIPROGRESS lpProgress,
  ULONG ulFlags
);

Parameters

  • lpMsgList
    [in] A pointer to an ENTRYLIST structure that contains the number of messages to delete and an array of ENTRYID structures that identify the messages.

  • ulUIParam
    [in] A handle to the parent window of the progress indicator. The ulUIParam parameter is ignored unless the MESSAGE_DIALOG flag is set in the ulFlags parameter.

  • lpProgress
    [in] A pointer to a progress object that displays a progress indicator. If NULL is passed in lpProgress, the message store provider displays a progress indicator by using the MAPI progress object implementation. The lpProgress parameter is ignored unless the MESSAGE_DIALOG flag is set in the ulFlags parameter.

  • ulFlags
    [in] A bitmask of flags that controls how the messages are deleted. The following flags can be set:

    • DELETE_HARD_DELETE
      Permanently removes all messages, including soft-deleted ones.

    • MESSAGE_DIALOG
      Displays a progress indicator as the operation proceeds.

Return Value

  • S_OK
    The specified message or messages were successfully deleted.

  • MAPI_W_PARTIAL_COMPLETION
    The call succeeded, but not all of the messages were successfully deleted. When this warning is returned, the call should be handled as successful. To test for this warning, use the HR_FAILED macro. For more information, see Using Macros for Error Handling.

Remarks

The IMAPIFolder::DeleteMessages method deletes messages from a folder. Messages that do not exist, that have been moved elsewhere, that are open with read/write permission, or that are currently submitted cannot be deleted.

Notes to Implementers

When the delete operation involves more than one message, perform the operation as completely as possible for each folder, even if one or more of the messages cannot be deleted. 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.

Notes to Callers

Expect these return values under the following conditions.

Condition

Return value

DeleteMessages has successfully deleted every message.

S_OK

DeleteMessages was unable to successfully delete every message and subfolder.

MAPI_W_PARTIAL_COMPLETION or MAPI_E_NOT_FOUND

DeleteMessages was unable to complete.

Any error value except MAPI_E_NOT_FOUND

When DeleteMessages is unable to complete, do not assume that no work was done. DeleteMessages might have been able to delete one or more of the messages before encountering the error.

DeleteMessages returns MAPI_W_PARTIAL_COMPLETION or MAPI_E_NOT_FOUND, depending on the message store's implementation.

MFCMAPI Reference

For MFCMAPI sample code, see the following table.

File

Function

Comment

FolderDlg.cpp

CFolderDlg::OnDeleteSelectedItem

MFCMAPI uses the IMAPIFolder::DeleteMessages method to delete the specified messages.

See Also

Reference

ENTRYID

ENTRYLIST

IMAPIFolder : IMAPIContainer

Concepts

MFCMAPI as a Code Sample

Using Macros for Error Handling