Hey Guys I am a newbie in office addin programming and now I am working on creating an addin for outlook. The purpose of this outlook addin is to fetch all incoming mails in each account's inbox and send them to my server. I've successfully done it with Microsoft.Office.Interop.Outlook , though I have some problems with it. Here is my code http://pastebin.com/TwnmrYeY and below are the problems
I hope you guys can help me since I've been stuck pretty long in these stuffs.
Firstly, Outlook Object Model cannot be used on a secondary thread in an Outlook addin - starting with Outlook 2013, Outlook will raise an exception as soon as it detects access to one of its objects on a secondary thread. Note that external exes marshal all OOM calls to the primary Outlook thread even if in that exe OOM is used on a secondary thread. To ve able to access various Outlook obejcts on a secondary thread, you need to use either Extended MAPI (C++ or Delphi) or the a wrapper like Redemption (its RDO family of objects can be used in secondary threads ).
Secondly, while Application.Quit event mostly won't fire, you can still detect the last Explorer or Inspector closing (Explorer.Close nad Inspector.Close events) - as soon as the last Outlook window is closed, Outlook will exit. That can also help prevent Outlook for exiting: if yo uhold a reference to an Inspector or Explorer object (even if it is not visible), Outlook will stay running.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.