Multithreading in Outlook

  • Thread starter Vladimir Chtchetkine
  • Start date
V

Vladimir Chtchetkine

Hi everybody!

Pretty much generic question :) How do I do my own multithreading in
Outlook? Straight forward path has failed (just as I suspected :) If
I create my own thread (using SDK's _beginthreadex call) there are
certain operations that lead to disaster :) For instance, when I try
to get Actions (pretty much innocent, huh?) on a Mail item that I just
created (in the context of the same thread) Outlook throws "Unable to
install custom action" (or something similar to that) msg box and
hangs.
I tried (in three different attempts) to call CoInitialize,
CoInitializeEx(multithreaded) OleInitialize in the beginning of my
thread execution but neither one seemed to be able to change anything.
So, HOW DO I DO multithreading in Outlook?

TIA,

Vladimir
 
D

Dmitry Streblechenko \(MVP\)

Outlook Object Model is not multithread safe. Why exactly do you need a
separate thread? Is there a specific Outlook method that takes too long to
execute?

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

Vladimir Chtchetkine

Well, sort of solved. I need some comments (I mean I would appreciate
them) on the approach...
In my OnStartupComplete handler I create a (hidden) window and
whenever I need to touch outlook API from an arbitrary thread (that
I've created or my async events use) I send a message to that window
(so, I have some messaging protocol) and in my window's message
handler I actually do what I need using Outlook API. I tested on the
problem that inspired initial post and it works just fine. But I
wander if that's THE approach I should take. Any comments?

TIA,

Vladimir
 

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