L
Luk
I wan't to have something like this:
I add items to Items collection and I do not wan't to handle the event (at
startup) and after I add some of those items I wan't to start handling the
ItemAdd event.
My code looks like this:
class Folder
{
private Outlook.Folder _folder = null;
private Outlook.Items _items = null;
private Logic.ContactsLogic _contactsLogic = null;
public Folder(Outlook.NameSpace outlook, string folderName)
{
Outlook.Folder defaultCalendarFolder =
(Outlook.Folder)outlook.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
_folder = GetFolder(defaultCalendarFolder, folderName);
_items = _folder.Items;
_contactsLogic = new ContactsLogic();
// In here I add some items to the folder
_contactsLogic.SynchronizeContacts(this);
HookUpEvents();
}
private void HookUpEvents()
{
_folder.BeforeFolderMove += new
Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeFolderMoveEventHandler(Folder_BeforeFolderMove);
_folder.BeforeItemMove += new
Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(Folder_BeforeItemMove);
_items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
_items.ItemChange += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemChangeEventHandler(Items_ItemChange);
_eventsHookedUp = true;
}
}
Although I add event handlers after I add the Items to the collection (in
statement _contactsLogic.SynchronizeContacts(this); ) I still get to handle
them in Items_ItemAdd and I don't wan't to
I add items to Items collection and I do not wan't to handle the event (at
startup) and after I add some of those items I wan't to start handling the
ItemAdd event.
My code looks like this:
class Folder
{
private Outlook.Folder _folder = null;
private Outlook.Items _items = null;
private Logic.ContactsLogic _contactsLogic = null;
public Folder(Outlook.NameSpace outlook, string folderName)
{
Outlook.Folder defaultCalendarFolder =
(Outlook.Folder)outlook.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
_folder = GetFolder(defaultCalendarFolder, folderName);
_items = _folder.Items;
_contactsLogic = new ContactsLogic();
// In here I add some items to the folder
_contactsLogic.SynchronizeContacts(this);
HookUpEvents();
}
private void HookUpEvents()
{
_folder.BeforeFolderMove += new
Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeFolderMoveEventHandler(Folder_BeforeFolderMove);
_folder.BeforeItemMove += new
Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(Folder_BeforeItemMove);
_items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
_items.ItemChange += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemChangeEventHandler(Items_ItemChange);
_eventsHookedUp = true;
}
}
Although I add event handlers after I add the Items to the collection (in
statement _contactsLogic.SynchronizeContacts(this); ) I still get to handle
them in Items_ItemAdd and I don't wan't to