View Single Post
  #1  
Old March 4th 09, 02:34 PM posted to microsoft.public.outlook.program_addins
Jason
external usenet poster
 
Posts: 41
Default ItemRemove event stop firing, ItemAdd & ItemChange still work

I'm in deep water now. The item deletion has been worked fine but suddenly
stop working. The ItemRemove event stops firing. But the add and change
still work fine. I don't know what cause that.

I do declare variables in the class level, following the advices in the
article "mstehle: The CDOs and CDONTS of Messaging Development"
http://blogs.msdn.com/mstehle/archiv...op-firing.aspx.

Here is my code:

public partial class ThisAddIn
{
// appointment related
private Outlook.Explorer explorer;
private Outlook.Items items;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
try
{
/******* appointment related event handler registration
*********/

//explorer = this.Application.ActiveExplorer();
//explorer.SelectionChange += new
Outlook.ExplorerEvents_10_SelectionChangeEventHand ler(ThisAddIn_SelectionChanged);

//openInspectors = this.Application.Inspectors;
//openInspectors.NewInspector += new
Outlook.InspectorsEvents_NewInspectorEventHandler( ThisAddIn_NewInspector);

Outlook._NameSpace ns =
this.Application.GetNamespace("MAPI");
Outlook.MAPIFolder calendarFolder =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derCalendar);
items = calendarFolder.Items;

items.ItemAdd += new
Outlook.ItemsEvents_ItemAddEventHandler(ThisAddIn_ CalenmdarItemAdded);
items.ItemChange += new
Outlook.ItemsEvents_ItemChangeEventHandler(ThisAdd In_CalenmdarItemChanged);
items.ItemRemove += new
Outlook.ItemsEvents_ItemRemoveEventHandler(ThisAdd In_CalenmdarItemRemoved);
}
catch (Exception ex)
{
...
}
}

private void ThisAddIn_CalenmdarItemAdded(object item)
{
}

private void ThisAddIn_CalenmdarItemChanged(object item)
{
}

private void ThisAddIn_SelectionChanged()
{
}

private void ThisAddIn_CalenmdarItemRemoved()
{
}

private void ThisAddIn_NewInspector(Outlook.Inspector newInspector)
{
Marshal.ReleaseComObject(newInspector);
}


Ads