Platform SDK: MAPI

IMAPIProp::GetLastError

The IMAPIProp::GetLastError method returns a MAPIERROR structure containing information about the previous error.

Quick Info

See IMAPIProp : IUnknown.

HRESULT GetLastError(
  HRESULT hResult,                
  ULONG ulFlags,                  
  LPMAPIERROR FAR * lppMAPIError  
);
 

Parameters

hResult
[in] HRESULT data type containing the error code generated in the previous method call.
ulFlags
[in] Bitmask of flags that indicates the format for the text returned in the MAPIERROR structure pointed to by lppMAPIError. The following flag can be set:
MAPI_UNICODE
The strings should be in Unicode format. If the MAPI_UNICODE flag is not set, the strings should be in ANSI format.
lppMAPIError
[out] Pointer to a pointer to the MAPIERROR structure containing version, component, and context information for the error. The lppMAPIError parameter can be set to NULL if there is no error information to return.

Return Values

S_OK
The error information was returned.
MAPI_E_BAD_CHARWIDTH
Either the MAPI_UNICODE flag was set and the implementation does not support Unicode, or MAPI_UNICODE was not set and the implementation only supports Unicode.

Remarks

The IMAPIProp::GetLastError method supplies information about a prior method call that failed. Clients can provide their users with detailed information about the error by including the data from the MAPIERROR structure in a dialog box.

All of the implementations of GetLastError provided by MAPI are ANSI implementations except for the IAddrBook implementation. The GetLastError method included with IAddrBook supports Unicode on Windows NT platforms only.

Notes to Implementers

The specifics of a remote transport provider's implementation of this method and what messages this method returns are up to the transport provider, since the particular error conditions which lead to various HRESULT values will be different for different transport providers.

Notes to Callers

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

To release the memory for the MAPIERROR structure, call MAPIFreeBuffer.

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

See Also

MAPIERROR, MAPIFreeBuffer