Is MAPI multithread-friendly?

  • Thread starter Vladimir Chtchetkine
  • Start date
V

Vladimir Chtchetkine

Unlike Outlook API? I mean it's known that Outlook's API is safely available
only within context of a UI thread. In an arbitrary thread OutlAPI fails
(sometimes). Is MAPI free from this restriction?

What I'm thinking to do (as a solution to my problem with preview pane
described in another post in this group) is working directly with MAPIOBJECT
(which is IMessage) for each item I need to touch in an arbitrary thread.
So, basically, the solution that I have in mind is:

1. When initializing my addin I build a list of IMAPIFolders that I'm
interested in.

2. For each IMAPIFolder list and save all item's EntryIDs (PR_ENTRYID)

3. Create a regular thread (with _beginthread for those of you who's
familiar with SDK) for synchronizing folder's content with some external
data server.

4. In this thread use IMAPIFolder.OpenEntry using entry ID for each entry
listed in step 2

5. Sync that item using its MAPI (IMessage) interface



How that looks to the experts? :)
 
D

Dmitry Streblechenko

Yes, that should work fine. Note however that MailItem.MAPIOBJECT returns
Outlook's wrapper, not the real Imessage returned by the store provider.
Messages returned by IMAPISession::OpenEntry, ImsgStore::OpenEntry, etc are
fine.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
V

Vladimir Chtchetkine

Thanks, Dmitry!

Well, I'm happy that long ago I decided to use PostItem as my base item :)
But still, I wander how do I get real IMessage out of a MailItem? Do I have
to do it by getting its EntryID and then reopen it with OpenEntry or there
is another way?

TIA,

Vladimir
 
D

Dmitry Streblechenko

Depends on what you are trying to do. If your processing occurs in another
thread, opening it by entry id is your only option.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top