Friday, November 26, 2004

MAPI MsgStore Provider and Outlook 2002/2003 Spooler

This post is result of my investigation why my own implementation of MAPI IMsgStore interface works with spooler under Outlook 2000 but does not under Outlook 2002/2003. So Outlook 2000 was the last version that was MAPI specification compliant. It has a separate spooler process named MAPISP32.EXE. In Outlook version since 2002(XP) Microsoft removed spooler as separate process and implemented it as a thread in MAPI application. I won't describe any additional changes of spooler API. The main problem is that IMSLogon::SpoolerLogon function is never called under Outlook XP. So i started digging. Most people used MSLMS sample from "Inside MAPI" book as a start point for implementing custom MsgStore provider. So did I. I analysed logs from my provider and logs from MSPST. First thing i noticed is that MSPST returns additional security data. See a peace of code below. STDMETHODIMP CMSProvider::Logon( LPMAPISUP pSupObj, ULONG ulUIParam, LPTSTR pszProfileName, ULONG cbEntryID, LPENTRYID pEntryID, ULONG ulFlags, LPCIID pInterface, ULONG * pcbSpoolSecurity, LPBYTE * ppbSpoolSecurity, LPMAPIERROR * ppMAPIError, LPMSLOGON * ppMSLogon, LPMDB * ppMDB) { static ULONG ulSpoolSecurity = 0; ... MAPIAllocateBuffer(sizeof(ulSpoolSecurity), (LPVOID*)pbSpoolSecurity); *pcbSpoolSecurity = sizeof(ulSpoolSecurity); ... } Actualy MSPST provider returns just security stub for spooler context. But it seems that it makes MAPI subsystem to call SpoolerLogon method of custom provider. Another issue is to add PR_MBD_PROVIDER property to the StatusRow table (via IMAPISupport::ModifyStatusRow). As a result i have modified MSLMS sample based on modified sample that Stephen Griffin posted in his blog. Download updated files. With this sample i managed to send mail using spooler under Outlook XP. Under Outlook 2000 it crashes while sending mail due to some named properties problems.