简体   繁体   中英

C# VSTO Outlook 2013 - Explorer Close handle Save Event

I have a RibbonBar with some Buttons that appears in the Outlook Explorer (Double Click on a mail).

Some progresses in the background edit the attachments of the mail. If the user close the Explorer, outlook will ask to save the edited mail (save the changes).

is there a Event to handle this? i don't want that the message appear if my programm has changed the mail.

I wasn't succesfull on the search for an Event. But maybe i just missed something.

There is no need to handle any event for this.

If the user close the Explorer, outlook will ask to save the edited mail (save the changes).

This is a good indicator that changes were not saved or Outlook objects (actually underlying COM objects) were not released correctly. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about that in the Systematically Releasing Objects article in MSDN.

Some progresses in the background edit the attachments of the mail.

Don't use the Outlook object model from secondary threads. Office applications (Outlook in your case) use the single threaded apartment model. You can gather the required info on the main thread (keep it in a string for example) and process it on another thread. Or you can use a low-level API (Extended MAPI) which allows to run multiple threads. Also you may consider using any wrapper around that API. Frankly speaking, Outlook is a big wrapper around that API.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM