MAPIInitialize 0x80004005

Discussion in 'Microsoft Outlook Discussion' started by simone, Aug 4, 2003.

  1. simone

    simone Guest

    I wrote a huge program which reads outlook contacts and works
    perfectly... almost. On one computer MAPIInitialize returned
    0x80004005. Now, I know that there is an issue regarding the version
    of Outlook used. However, this cannot be the case because Outlook Spy
    works fine on the same system. Any ideas why?

    On other matters, I understand that Extended MAPI allowed me to read
    the contacts from the Outlook Corporate Edition. Can this code also
    get the WAB?
    simone, Aug 4, 2003
    1. Advertisements

  2. Is Outlook set as the default mail client?

    Dmitry Streblechenko (MVP)
    OutlookSpy - Outlook, CDO
    and MAPI Developer Tool
    Dmitry Streblechenko, Aug 8, 2003
    1. Advertisements

  3. simone

    simone Guest

    Turns out that was the problem. Outlook was not the default client. I
    understand that a program such as Outlook Spy actually uses the EMAPI
    DLL rather then the DLL specified by the default client. My program
    failed because it was using the DLL of the default client, which was
    Outlook Express at the time. Which leads me to ask... how do I set my
    program to always use the EMAPI DLL?

    Also, if anyone can help:
    1) Can EMAPI code be used to read the contact from Outlook Express,
    namely the WAB?
    2) Can the same EMAPI code read the contact lists from a Notes client?
    I have no such client and hence cannot even test.
    simone, Aug 11, 2003
  4. You need to set a registry key - see below for an MSDN topic.
    1. Strictly speaking, no. But there is WAB API which looks exactly like
    Extended MAPI (see WABOpen on MSDN)
    2. Yes, if you have Notes MAPI providers (store, Address Book, etc)
    installed so that Outlook can connect to a Notes DB. If not, you can use the
    Notes API - it is fairly powerful, but very low level and much uglier than
    Extended MAPI IMHO.

    Dmitry Streblechenko (MVP)
    OutlookSpy - Outlook, CDO
    and MAPI Developer Tool

    Explicitly Mapping MAPI Calls to MAPI DLLs
    In some cases, MAPI calls made from a particular DLL or executable file need
    to be routed to the system MAPI DLL (called Mapi32x.dll) or another custom
    MAPI DLL even though the default mail client supports the call. Such DLLs or
    executables files can be listed as string registry values in the
    HKLM\Software\Microsoft\Windows Messaging Subsystem\MSMapiApps key. The
    registry value for these keys can be empty or identify a mail client key
    that resides under HKLM\Software\Clients\Mail.

    When the stub library resolves a MAPI call, it first enumerates the DLL and
    executable files listed under the HKLM\Software\Microsoft\Windows Messaging
    Subsystem\MSMapiApps key checking to see if the DLL or executable file is
    currently in process. If there is a match, the stub library gets the string
    value. If the value is the empty string, the stub library routes the call to
    the system MAPI DLL, Mapi32x.dll. If the string is not empty, the stub uses
    the string value to find the key below HKLM\Software\Clients\Mail where it
    can find the appropriate registry value to dispatch the call, one of
    DLLPath, DLLPathEx, or MSIComponentID values. For example:

    HKLM\Software\Microsoft\Windows Messaging Subsystem\MSMapiApps::exchng32.exe
    = ""
    (route call directly to Mapi32x.dll)

    HKLM\Software\Microsoft\Windows Messaging Subsystem\MSMapiApps::msspc32.dll
    = "Microsoft Outlook"
    (route call using Microsoft Outlook key under HKLM\Software\Clients\Mail)
    Dmitry Streblechenko, Aug 11, 2003
  5. simone

    Tom Delany Guest

    Nothing could be uglier than extended MAPI. ;-)

    The Notes C++ API is much better than the C API. In some areas, it (the C++
    API) is a little flaky, however (IMHO). Alas, the Notes APIs will do you
    absolutely no good if you do not have the Notes client, as they use DLLs
    from the client to do their job.

    Tom Delany
    Tom Delany, Aug 11, 2003
  6. simone

    simone Guest

    2. Yes, if you have Notes MAPI providers (store, Address Book, etc)
    Thanks Dimitry. I recently got hold of Notes and I am running it now.
    There is a DLL called nmailman.dll which looks similar to the Extended
    MAPI from Outlook that I've been using. For starters, this DLL has
    MAPIInitialize. My understanding was that my current code gets
    rerouted to whichever DLL is running on our client. In which case,
    when Notes is the default mail client then I would expect that my code
    would be rerouted (via the registry) to the Notes MAPI DLL. But on
    testing, MAPIInitialize fails... hence either I am calling the wrong
    DLL or else I am completely misunderstanding how to hook into Lotus
    Notes. Advice?

    BTW, your OutlookSpy is excellent and we recently got ourselves a
    copy. I *HIGHLY* recommend it to all developers.
    simone, Aug 18, 2003
  7. The MAPI redirection works for Simple MAPI calls mostly. If you are using
    the Notes provider, you still need to call the regular msmapi32.dll. If
    Notes provider is installed in the current MAPI session, your calls to any
    store related objects (IMsgStore, IMAPIFolder, IMessage, etc) will go to the
    Notes implementation of these object, no extra coding on your part required.

    Dmitry Streblechenko (MVP)
    OutlookSpy - Outlook, CDO
    and MAPI Developer Tool
    Dmitry Streblechenko, Aug 18, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.