The IMSLogon::GetLastError method returns a MAPIERROR structure containing information about the last error that occurred for the message store object.
See IMSLogon : IUnknown.
HRESULT GetLastError(
HRESULT hResult,
ULONG ulFlags,
LPMAPIERROR FAR * lppMAPIError
);
Use the IMSLogon::GetLastError method to retrieve information to display in a message to the user regarding the last error returned from a method call for the message store object.
To release all the memory allocated by MAPI for the returned MAPIERROR structure, client applications need only call the MAPIFreeBuffer function.
The return value from GetLastError must be S_OK for an application to make use of the MAPIERROR structure. Even if the return value is S_OK, a MAPIERROR structure might not be returned. If the implementation cannot determine what the last error was, or if a MAPIERROR structure is not available for that error, GetLastError returns a pointer to NULL in lppMAPIError instead.