Microsoft KB Archive/315500

= PRB: You Receive the MAPI_E_FAILURE (2) MAPI Result Code If You Use Some Hotmail Simple MAPI functions =

Article ID: 315500

Article Last Modified on 3/19/2004

-

APPLIES TO


 * Simple Messaging Application Programming Interface (MAPI)
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer (Programming) 6.0

-



This article was previously published under Q315500



SYMPTOMS
If you have Microsoft MSN Hotmail set as your default e-mail client, you may receive the MAPI_E_FAILURE (2) MAPI result code when you call Simple MAPI functions other than MAPISendMail, MAPILogon, and MAPILogoff. You may also receive with MAPI_E_FAILURE (2) MAPI result code if you use a Microsoft Visual Basic code to call the MAPISendMail function.



CAUSE
This behavior can occur because the Hotmail Simple MAPI that is included with Microsoft Internet Explorer and that is contained in the Hmmapi.dll file only implements the three functions exported as MAPISendMail, MAPILogon, and MAPILogoff. All other Simple MAPI functions that are exported by the Hmmapi.dll file return the MAPI_E_FAILURE (2) MAPI result code.

This includes the BMAPI functions, such as BMAPISendMail, which are typically exported by Simple MAPI implementations to allow Visual Basic programs to call them. The BMAPI functions use simpler structures that Visual Basic can understand. Hotmail does not implement any of the BMAPI functions. Any call to them returns with the MAPI_E_FAILURE (2) MAPI result code.



RESOLUTION
To resolve this behavior, limit the use of Simple MAPI to the MAPISendMail function and do not use the BMAPI functions if you are using Hotmail as your default e-mail client.



STATUS
This behavior is by design.



MORE INFORMATION
Hotmail provides a Simple MAPI implementation in the following file:

%Program Files%\Internet Explorer\Hmmapi.dll

If you are using Hotmail as your default e-mail client, then the following key

HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail::(default)

will be set to HotMail.

This causes the MAPI Stub Library (the Mapi32.dll file) to route Simple MAPI calls to the Hmmapi.dll file.

A client program can link directly to the functions in the Hmmapi.dll file by calling LoadLibrary. It is not recommended that you use this method.

The following list describes how each of the implemented Simple MAPI functions operate:
 * MAPILogon: Sets lhSession to 1, and returns SUCCESS_SUCCESS.
 * MAPILogoff: Always returns SUCCESS_SUCCESS
 * MAPISendMail: Ignores lhSession. Ignores all flags, including MAPI_DIALOG. Invokes Internet Explorer to create a message in a compose window by using the passed in MapiMessage structure, including all recipients and attached files. The message is created and presented in the browser, but it is not automatically sent. You must manually send the message. Because this function invokes a user interface, do not use it from a service.

