Last modified: July 23, 2011

Applies to: Outlook

In this article
Notes to Callers
Notes to Implementers
MFCMAPI Reference

Deletes the current message.

HRESULT DeleteMessage(
  LPCRECT prcPosRect


[in] A pointer to a view context object.


[in] A pointer to a RECT structure that contains the current form's window size and position. The next form displayed also uses this window rectangle.


The call succeeded and has returned the expected value or values.


The operation is not supported by this message site.

A form object calls the IMAPIMessageSite::DeleteMessage method to delete the message that the form is currently displaying.

Following the return of DeleteMessage, form objects must check for a new message and then dismiss themselves if none exists. To determine whether the message DeleteMessage acted on was deleted or moved to a Deleted Items folder, a form object can call the IMAPIMessageSite::GetSiteStatus method to determine whether the DELETE_IS_MOVE flag was returned.

If a form viewer's implementation of the DeleteMessage method moves to the next message after it deletes a message, the implementation should call the IMAPIViewContext::ActivateNext method and pass the VCDIR_DELETE flag before performing the actual deletion. If a form viewer's implementation of DeleteMessage moves the deleted message (for example, to a Deleted Items folder), the implementation must save changes to the message if the message was modified.

A typical implementation of DeleteMessage performs the following tasks:

  1. If the implementation is moving the message, it calls the IPersistMessage::Save method, passing null in the pMessage parameter and true in the fSameAsLoad parameter.

  2. It calls the IMAPIViewContext::ActivateNext method, passing the VCDIR_DELETE flag in the ulDir parameter.

  3. If the ActivateNext call fails, it returns. If ActivateNext returns S_FALSE, it calls the IPersistMessage::HandsOffMessage method.

  4. It deletes or moves the message.

To obtain the RECT structure used by a form's window, call the Windows GetWindowRect function.

For a list of interfaces related to form servers, see MAPI Form Interfaces.

For MFCMAPI sample code, see the following table.






Not implemented.

© 2015 Microsoft