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



The information in this article applies to:

  • Simple Messaging Application Programming Interface (MAPI)
  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 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.

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

163216 Updated Mapivb32.bas for Simple MAPI on 32-Bit Platforms

315458 PRB: Simple MAPI BMAPI Functions Might Not Work With MAPI Stub Library


Modification Type:MajorLast Reviewed:3/19/2004
Keywords:kbprb KB315500