none
Running Multiple Thread in Outlook Object model RRS feed

Answers

  • You can have as many secondary threads in your addin as you want as long as you don't touch Outlook Object Model objects in any of them.

    Starting with Outlook 2013, it will raise an error outright as soon as it detects an OOM object being accessed on a thread other than the main Outlook thread. And if you (or .Net run-time) marshals the call, it will be marshaled to the main Outlook thread, which defeats the whole purpose.

    You can

    1. Use Extended MAPI (C++ or Delphi only) - Namespace.MAPIOBJECT returns IMAPISession, MailItem.MAPIOBJECT will give you IMessage MAPI object, etc.

    2. Redemption (any language) - its RDO family of objects is thread safe.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, October 15, 2014 5:39 AM
  • Most Office applications (Outlook too) use single threaded apartments (STA). That's why you need to access Outlook properties and methods from the main thread only.

    You can work with low-level code (Extended MAPI) in managed applications. But that way is not officially supported by MSFT. I.e. if you face with any issue, nobody will help you. You will be asked to use any unmanaged wrapper like Redemption.

    Wednesday, October 15, 2014 12:11 PM

All replies

  • You can have as many secondary threads in your addin as you want as long as you don't touch Outlook Object Model objects in any of them.

    Starting with Outlook 2013, it will raise an error outright as soon as it detects an OOM object being accessed on a thread other than the main Outlook thread. And if you (or .Net run-time) marshals the call, it will be marshaled to the main Outlook thread, which defeats the whole purpose.

    You can

    1. Use Extended MAPI (C++ or Delphi only) - Namespace.MAPIOBJECT returns IMAPISession, MailItem.MAPIOBJECT will give you IMessage MAPI object, etc.

    2. Redemption (any language) - its RDO family of objects is thread safe.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, October 15, 2014 5:39 AM
  • Most Office applications (Outlook too) use single threaded apartments (STA). That's why you need to access Outlook properties and methods from the main thread only.

    You can work with low-level code (Extended MAPI) in managed applications. But that way is not officially supported by MSFT. I.e. if you face with any issue, nobody will help you. You will be asked to use any unmanaged wrapper like Redemption.

    Wednesday, October 15, 2014 12:11 PM