Share via


IMAPIMessageSite::DeleteMessage

Applies to: Office 2010 | Outlook 2010 | Visual Studio

In this article
Notes to Callers
Notes to Implementers
MFCMAPI Reference

Deletes the current message.

HRESULT DeleteMessage(
  LPMAPIVIEWCONTEXT pViewContext,
  LPCRECT prcPosRect
);

Parameters

  • pViewContext
    [in] A pointer to a view context object.

  • prcPosRect
    [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.

Return Value

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

  • MAPI_E_NO_SUPPORT
    The operation is not supported by this message site.

Remarks

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

Notes to Callers

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.

Notes to Implementers

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.

MFCMAPI Reference

For MFCMAPI sample code, see the following table.

File

Function

Comment

MyMAPIFormViewer.cpp

CMyMAPIFormViewer::DeleteMessage

Not implemented.

See Also

Reference

IMAPIMessageSite::GetSiteStatus

IMAPIViewContext::ActivateNext

IPersistMessage::HandsOffMessage

IPersistMessage::Save

IMAPIMessageSite : IUnknown

Concepts

MFCMAPI as a Code Sample

MAPI Form Interfaces