LPMAPISESSION Advice Appreciated

LPMAPISESSION Advice Appreciated

Post by Russell Ma » Fri, 17 Mar 2006 17:22:31


Hi,
I am designing an un-managed Win32 console application in VS2005 that will
be called from Windows 2000/3 Task Scheduler, the application will use
LPEXCHANGEMANAGESTORE (wow that's a long name), the application processes
mailboxes and public folder message stores and archives messages to an SQL
Server database. I will be using Exchange's MAPI32.DLL (not Outlook).

My question:
Is there any problem with wrapping LPMAPISESSION inside a singleton class
library, or simply keeping the MAPI session alive during a mailbox run. I
would like to do what MAPI likes the best. Here is an example of what a
mailbox run looks like. Here is some pseudo-code that describes the process.

1. Query Active Directory for List of Alias and ServerName (mailboxes to
archive).
2. MAPIInitialize()
3. OpenFirstMessageStore(Alias, ServerName).
4. Loop through all folders.
5. Update SQL DataBase with FolderHierarchy.
6. GetTheMessagesToArchive
7. Update SQL DataBase with Messages & Attachments
8.MAPIUninitialize()
9. Repeat the process, GOTO #2

There will usually be 50-100 mailboxes which will be archived, and so the
previous routine would Initialize and Uninitialize MAPI 50-100 times, once
each time for each mailbox.

OR

I could Initialize MAPI once at the beginning and hang on to the
LPMAPISESSION during the entire run and then MAPIUninitialize().

What would MAPI like me to do?

Thanks for your advice.

Russell Mangel
Las Vegas, NV
 
 
 

LPMAPISESSION Advice Appreciated

Post by Pete Macle » Sun, 19 Mar 2006 00:38:47


I cannot give any objective justification for this but I would certainly
choose the latter course. Either will work well but my sense, based on
years of experience, is that it is better to initialize/uninitialize MAPI
once and once only.

Pete Maclean