vsto outlook ItemAdd event on a public folder on Exchange
http://stackoverflow.com/questions/8562214/itemadd-event-on-a-public-folder-on-exchange
Continuous googling did its job. I found how to resolve the issue. It appears I am not the only one who experience it.
I added the reference to Items collection of the folder I want to track to the global scope:
internal static class stor
{
public static Outlook.Items i;
}
public partial class ThisAddIn
{
internal static Outlook.Folder posts_folder = null;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
// the code for finding a posts_folder is omitted
stor.i = posts_folder.Items;
stor.i.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(Posts_Add);
}
static void Posts_Add(object Item)
{
System.Windows.Forms.MessageBox.Show("New item");
}
{
Now it works as expected. Alhough I do not understand all the details they say it is a garbage collection issue. My event handler eventually was thrown into the garbage. The reference to the Items collection on the global scope prevents this from happening.
http://social.msdn.microsoft.com/Forums/en-AU/vsto/thread/28d91a1a-34ec-476d-8f49-0d26aff8a376http://stackoverflow.com/questions/8562214/itemadd-event-on-a-public-folder-on-exchange
댓글 없음:
댓글 쓰기