Updated MSLMS Sample Posted

A while back, I posted an article about the fixes Jason and I had to make to the MSLMS sample message store to get it to load under Outlook 2003. Since then, I’ve received numerous requests that I post the changes. I wasn’t ignoring the requests – I’ve just been busy adding features to MFCMAPI (more on that later).

Before I posted the code, I wanted to scrub it once more for obvious defects. We have some tools here which can point out potential bugs in your code, like dereferencing a pointer without first checking that it’s not NULL. I was amazed at the volume of errors these scripts found in the sample. Even though most of these errors were trivial to fix, the number of them made for slow goings.

Anyway, here’s the updated code. Fair warning: There’s no warrenty whatsoever implied in this code. USE THIS CODE AT YOUR OWN RISK!

Todo list:

  • Scrub each individual function for coding errors – make sure all parameters are checked and all variables properly initialized
  • Remove all old tracing code and replace it with something more modern
  • Remove all code wrapped in assert/verify macros and replace with real error handling
  • Remove all gotos
  • Remove dead code
  • Add error handling for all function calls
  • Replace all string handling functions with equivalent StrSafe functions
  • Revisit my fix for the heap management issues

I’ll post updates as I make major changes and bug fixes. I may create a workspace for this on gotdotnet if I see enough interest in it. Until I do, send any bug reports to me.

[edit – crediting JasonJoh for the work he did on this]

Comments (10)

  1. Henry Ghusakovsky says:

    I’ve found some additional errors in the posted sample.

    And there is a big leak of functionality as a default Store: It can’t send mail via spooler. May be it’s better to say that spooler suppopt is not completed.

    Another leak is Search Folders.

  2. My goal was to get the existing sample working, not to add new features. Search folders was never implemented in MSLMS.

    On sending mail – I don’t think MSLMS ever supported being the default store provider – I did some tests enabling it and the first roadblock I hit was when Outlook tries to store special folder entry IDs on the Inbox – CMAPIFolder::SetProps doesn’t allow for arbitrary props on folders. That problem is fixable, but leads into a second problem – we can’t create a Reminders folder since MSLMS doesn’t support search folders.

    I’m not sure I follow the spooler comment – given that the MSLMS sample has never supported being a default store, how would we expect it to ‘send mail via the spooler’?

  3. Henry Ghusakovsky says:

    I have fixed spooler problems and fixed a number of memory corrupting errors.

    Added another missing property in the Hierarchy tables.

    Allowed setting custom properties for folders.

    Fixed updating Content Tables (there was an error if some open properties present)

    Now it works better in my Outlook XP.

    So i can send you an updated project.

  4. Much appreciated – send me a mail via the contact link and we’ll coordinate from there.

  5. " I have fixed spooler problems and fixed a number of memory corrupting errors. "

    Any chance I can download the latest and greatest of the MSLMS?

    thanks in advance.

  6. I had some issues integrating Henry’s changes to the existing code – lot’s of memory corruption. I don’t know yet if it’s his changes or the way I integrated them or some combination of the two.

    Rather than rush through it and end up with an unstable build, I’m taking my time with this integration – unfortunately, I’m also very busy with some other projects so it may be a while before I post a new updated sample.

  7. Gwyn Cole says:

    Looking forward to the next stable build…

  8. mehdi says:

    hi dear Stephen.

    is it possible to compile you’r mslms sample in microsoft visual studio.net.

    i looking for .net samples and i found nothing, for writing store provider.

    is it any resource or sources that lead me.


  9. If by .Net you mean Visual Studio 2003/2005 unmanaged C++, then it should probably work, barring a few minor issues any project would have porting from one compiler to another.

    If by .Net you mean managed code like C# or managed C++, then that would fall into the category of mixing MAPI and managed code, which is a no-no.

  10. Documentation and sample for a Wrapped PST