locked
MAPI Issue RRS feed

  • Question

  • Hi,

    I am working with Exchange Server 2007 on Windows Server 2008 R2.  I have written a Win32 application that is trying to log on to Exchange Server and enumerate the mailbox information like email address and display name.

    However, the call hr = pMsgSvcAdmin->CreateMsgService((LPTSTR)"MSEMS", NULL, NULL, NULL); fails with error MAPI_E_NOT_FOUND.  I did install 'Exchange Server MAPI Client' from following location - http://www.microsoft.com/en-us/download/details.aspx?id=6248.

    I do have MAPISVC.INF at C:\Windows\SysWOW64.  It has all the necessary Services entries.  If required I can provide code and contents of MAPISVC.INF.

    I am struggling with this issue for last 3-4 days, any help will be appreciated.

    Thanks.

    Friday, July 6, 2012 2:45 PM

Answers

  • The error means the connection was blocked by the firewall or the server is not accessible.

    Have you try to turn the firewall off?

    The error is raised after the service is already added, so it looks like Redemption does not have the same problem - it can see the MSEMS service.

    How/from what folder do you load the MAPI dlls?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, July 13, 2012 6:44 PM
  • So you are statically linking to the MAPI dlls?

    You should not do that - look at the MFCMAPI source code for an example on how to load the right dlls.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!


    Monday, July 16, 2012 7:21 AM

All replies

  • Are you compiling for Unicode?

    CreateMsgService only takes an ANSI string.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, July 6, 2012 4:59 PM
  • Hi Dmitry,

    Yes, I am compiling for Unicode.  However, I am passing ANSI string to CreateMsgService.

    hr = pMsgSvcAdmin->CreateMsgService((LPTSTR)"MSEMS", NULL, NULL, NULL);

    I am casting it to LPWSTR to ensure that it compiles.

    Thanks.
    Friday, July 6, 2012 8:45 PM
  • Ah, sorry, you are right!

    Did you ever have Outlook installed on that machine?

    Does it work if you run your app on a machine with Outlook?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, July 6, 2012 9:01 PM
  • Hi Dmitry,

    No, I didn't install Outlook on that machine.  I didn't want Exchange Server MAPI to co-exist with Outlook MAPI, because I wanted to enumerate Exchange Server Mailboxes which I understand doesn't work with Outlook MAPI.  I will test the code with a machine that has Outlook installed and maybe another Exchange Server setup.  I will get back to you with the results once done.

    BTW, one more question I have is that for Exchange Server 2010 development should I continue with MAPI or move on to EWS?

    Thanks.


    Saturday, July 7, 2012 5:00 AM
  • Can you (as an experiment) download Redemption from the URL below and try the folloiwng VBS script?

    set Session = CreateObject("Redemption.RDOSession")
    Session.LogonExchangeMailbox "<your user name>", "<server name>"
    set Inbox = Session.GetDefaultFolder(6)
    MsgBox Inbox.Items.Count

    As for EWS vs MAPI, EWS is the way to go if you are dealing with hosted mailboxes since the standalone version of MAPI does not support ROH.

    But MAPI still has more functionality and provides much lower level access than EWS.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Saturday, July 7, 2012 9:00 PM
  • Hi Dmitry,

    I tried the code on my laptop, where outlook is installed.  The CreateMsgService() is successful, I haven't tested further because I don't have access to the Exchange Server test setup right now.  I think GetMailboxTable() will fail from Outlook MAPI. I am interested in Exchange Server side as my component will be running there.

    I will try Redemption and I will also try another Exchange Server setup.

    I working on a backup and recovery application.  Is MAPI being phased out?  Should I be moving on to EWS for Exchange Server 2010 and beyond?

    Thanks.

    Sunday, July 8, 2012 4:56 PM
  • Hi Dmitry,

    I tried on 4 Exchange Server test setups, same result MAPI_E_NOT_FOUND!

    Thanks.

    Monday, July 9, 2012 8:54 AM
  • Does Redemption script produce the same error?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Monday, July 9, 2012 2:00 PM
  • I tried redemption from a machine that has outlook and created default profile for the Exchange Server I am interested in.

    Following is the output.

    C:\>cscript Redemption.vbs
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.

    C:\Redemption.vbs(1, 1) (null): Wrong OS or OS version for application

    BTW, I have built a MAPI based Win32 application and I am trying to run it on x64.

    Tuesday, July 10, 2012 2:34 PM
  • That means you are using the 64 bit version of cscript.exe.

    Try to explicilty use the version from the SysWOW64 folder.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Tuesday, July 10, 2012 2:40 PM
  • I tried redemption based test from both the Exchange Server and a Outlook installed machine with default profile pointing to Exchange Server of interest.  Here is the output.

    G:\>c:\windows\syswow64\cscript.exe Redemption.vbs
    Microsoft (R) Windows Script Host Version 5.8
    Copyright (C) Microsoft Corporation. All rights reserved.

    G:\Redemption.vbs(2, 1) Redemption.RDOSession: Error in IMsgServiceAdmin::ConfigureMsgService: MAPI_E_NETWORK_ERROR

    Is EWS good enough for data protection in Exchange 2007?

    Wednesday, July 11, 2012 9:26 AM
  • The error means the connection was blocked by the firewall or the server is not accessible.

    Have you try to turn the firewall off?

    The error is raised after the service is already added, so it looks like Redemption does not have the same problem - it can see the MSEMS service.

    How/from what folder do you load the MAPI dlls?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, July 13, 2012 6:44 PM
  • Thanks for the reply.  On my setup I have two MAPI32.dlls.

    C:\>dir mapi32.dll /s
     Volume in drive C has no label.
     Volume Serial Number is 2A21-BEA3

     Directory of C:\Windows\System32

    21-11-2010  08:54            91,648 mapi32.dll
                   1 File(s)         91,648 bytes

     Directory of C:\Windows\SysWOW64

    21-11-2010  08:54            76,800 mapi32.dll
                   1 File(s)         76,800 bytes

    Using dependency walker I see that my application is linking with C:\Windows\System32\mapi32.dll.  I will test my application by linking to the other version of DLL. 

    Thanks again.

    Monday, July 16, 2012 7:14 AM
  • So you are statically linking to the MAPI dlls?

    You should not do that - look at the MFCMAPI source code for an example on how to load the right dlls.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!


    Monday, July 16, 2012 7:21 AM
  • Dmitry,

    Thanks for your help with this issue.  I will look at MFCMAPI code. 

    I was able to resolve this issue.  The issue was occurring because of a stale profile.  Once the profile was deleted I was able to move ahead.  Right now I am facing some other issues, I will look into them, if needed will get back to this forum.

    Thanks.

    Tuesday, July 17, 2012 6:42 AM