tags:

views:

1044

answers:

3

I'm looking to write an automated monitor script to programmatically retrieve information from another user's Exchange 2003 inbox. I have working C++ code to log into MAPI and connect to my own inbox. I can also use the Control Panel->Mail applet to configure another user's mailbox into my profile, and my code can access that way. However, this was done on my desktop with Outlook installed, which provides a richer mail profile editor.

Since this will run on a server, I'd prefer not to install Outlook at all. Instead, I can install the MAPI client. I then create a simple MAPI app that pops up the mail profile wizard using MAPILogonEx() with the MAPI_LOGON_UI flag. However, the basic MAPI client doesn't have the features to configure another user's mailbox. As a requirement, I can only run this script as the service account of the monitoring application, so I cannot tell it to run as the account whose mailbox I want.

Is it still possible to connect to another user's mailbox (assuming permissions are already granted) using the basic MAPI client? Or is it absolutely necessary to install Outlook for this functionality?

A: 

Have you looked into ConfigureMsgService? I believe that works with Exchange MAPI, or are you saying you tried that and it didn't work?

IMsgServiceAdmin::ConfigureMsgService will set the mailbox for the profile. What I was really looking for was a way to add _additional_ mailboxes. When you do this in Outlook, MAPI sees them as additional IMsgStore entries. Without Outlook, how can this be done?
spoulson
+1  A: 

I see... I'm not sure how to do that explicitly; that's usually a side effect of calling CreateStoreEntryID with the wrong flags. What's you're looking to do is probably:

  1. Get a IID_IExchangeManageStore from your default message store
  2. Call CreateStoreEntryID
  3. Then open that store by the entry ID

LPEXCHANGEMANAGESTORE mapiObject = NULL; store->QueryInterface( IID_IExchangeManageStore, (LPVOID *) &mapiObject); mapiObject->CreateStoreEntryID( server, mailbox, OPENSTORE_TAKE_OWNERSHIP | OPENSTORE_USE_ADMIN_PRIVILEGE, &len, &buffer); //Call OpenEntry on the entry id

If you want a more detailed example, search the source of the MFC MAPI project for CreateStoreEntryID. If you have other questions, the best place to get them answered is the microsoft.public.win32.programmer.messaging newsgroup.

My research on the topic agrees with this suggestion. However, finding the binaries and headers that give you IExchangeManageStore seems impossible; removed from MS download. Is it still available anywhere?
spoulson
+1  A: 

I would strongly recommend using the Microsoft Exchange MAPI Client (as you have linked). It is engineered to be far more robust than the Outlook version of these libraries. You should find the API no different between Outlook and Exchange Server with respect to Extended MAPI.

You will need to use Extended MAPI (as described by Cain T S Random) to open other mail stores, and of course your application will need to be logged in as the Windows user with appropriate permissions on the Exchange server.

Henk