Outlook add-in multithreading (plus)

  • Thread starter Thread starter Steve Gerrard
  • Start date Start date
S

Steve Gerrard

Hi,

I'm rather new at this outlook add-in development stuff, and though I've been trying to read as much background as possible before attacking the real thing, I seem to be missing quite a few essential elements, so please point me in the right direction if I'm completely off.

I'm trying to develop an add-in that would enable sending large attachments, much the same way as the yousendit outlook add-in, or its Adobe counterpart.

The first thing for me is trying to select the appropriate technology/framework/API.

I've read all over that the outlook object model has issues with multithreading, and since it's imperative for my add-in that the outlook GUI remains responsive while attachments are being uploaded in the background (before the sent mail item is actually sent or moved to the outbox), multithreading is a must. I've managed to gather some bits and pieces that lead me to believe MAPI could be my friend, but have not managed to find any concrete answer as to whether a MAPI add-in even exists: is it an alternative for the Outlook object model, or simply an additional API that can be used from within a VSTO/COM add-in?

So, my question is: can I use C# VSTO in order to develop an add-in that parses attachments in the background, while outlook remains responsive and functional? If so, is it simply a matter of starting a new background thread? Can you recommend any sample / how-to / open-source code / book that could get me started?

Another question I have, is regarding the events I should trap to perform what I've described above. Ideally, I'd like to parse the message while it's in the outbox, "releasing" it to be sent when I'm done. The thing is, I've tried trapping the ItemSend event, but the mailitem is still open when it fires, and the ItemAdd event does not consistently fire when listening on the outbox folder. I've seen the mentioned add-ins move relevant messages into a different folder when the Send button is clicked, and only when the upload is done the message is moved to the outbox and sent. How can that be accomplished, making the Send button move messages to a folder other than the outbox?

Hope it's not too much for a single post, I've just decided I'd better ask everything I'm missing after a week or so of reading confusing and contradicting material...

Any help would be greatly appreciated.

Thanks,
G..
Submitted using http://www.outlookforums.com
 
Extended MAPI cannot be used with any managed code, only with unmanaged code
and only there in C++ or Delphi. It also has a steep learning curve and is
not object oriented.

The Outlook object model can only be used from the main process thread, any
attempts to use it from a background thread will crash or hang Outlook
and/or cause other code running with Outlook to also crash. Not recommended
and not a good idea at all.

You can do all accesses to the object model in the foreground thread and
gather the data as data, then pass that to a background thread for
processing as long as that doesn't use the Outlook object model at all.

I mostly use the item.Send() event, using Application.ItemSend() usually is
too late in the process for what I want to do. Messing with items in the
Outbox after they are submitted to the mail transport will prevent the item
from being sent.

For lots of Outlook code samples and discussions of problems like this go to
www.outlookcode.com
 
Back
Top