J
Jason
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/archi...rt-1-introduction-why-events-stop-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_SelectionChangeEventHandler(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.olFolderCalendar);
items = calendarFolder.Items;
items.ItemAdd += new
Outlook.ItemsEvents_ItemAddEventHandler(ThisAddIn_CalenmdarItemAdded);
items.ItemChange += new
Outlook.ItemsEvents_ItemChangeEventHandler(ThisAddIn_CalenmdarItemChanged);
items.ItemRemove += new
Outlook.ItemsEvents_ItemRemoveEventHandler(ThisAddIn_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);
}
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/archi...rt-1-introduction-why-events-stop-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_SelectionChangeEventHandler(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.olFolderCalendar);
items = calendarFolder.Items;
items.ItemAdd += new
Outlook.ItemsEvents_ItemAddEventHandler(ThisAddIn_CalenmdarItemAdded);
items.ItemChange += new
Outlook.ItemsEvents_ItemChangeEventHandler(ThisAddIn_CalenmdarItemChanged);
items.ItemRemove += new
Outlook.ItemsEvents_ItemRemoveEventHandler(ThisAddIn_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);
}