Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Returns a MAPIERROR structure that contains information about the previous session error.

HRESULT GetLastError(
  HRESULT hResult,
  ULONG ulFlags,


[in] A handle to the error value generated in the previous method call.


[in] A bitmask of flags that controls the type of strings returned. The following flag can be set:


The strings in the MAPIERROR structure returned in the lppMAPIError parameter are in Unicode format. If the MAPI_UNICODE flag is not set, the strings are in ANSI format.


[out] A pointer to a pointer to a MAPIERROR structure that contains version, component, and context information for the error. The lppMAPIError parameter can be set to NULL if MAPI cannot supply appropriate information for a MAPIERROR structure.


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


The MAPI_UNICODE flag was set and the session does not support Unicode.

The IMAPISession::GetLastError method retrieves information about the last error that was returned by an IMAPISession method call. Clients can provide their users with detailed information about the error by including this information in a dialog box.

You can use the MAPIERROR structure, if MAPI supplies one, pointed to by the lppMAPIError parameter only if GetLastError returns S_OK. Sometimes MAPI cannot determine what the last error was, or it has nothing more to report about the error. In this situation, GetLastError returns a pointer to NULL in lppMAPIError instead.

For more information about the GetLastError method, see MAPI Extended Errors.

© 2015 Microsoft