Is your call to SynchronizeContacts synchronous or asynchronous? If it's
waiting to return until the synching is finished you should not get ItemAdd
events.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Luk" <Luk.RemoveThis@discussions.microsoft.com> wrote in message
news:39774F53-9FF4-4583-82CE-20433D65218F@microsoft.com...
>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