ContactItem.Save() --- Urgent Is their any Guru

V

Virda

Hello All,

I have a problem related to ContactItem. Save().

I am using VS2005 C# with MSOffice2003 outlook.

I am working on a AddIn for Outlook.

As my Addin load in application start function. I call a function that
register following two events:

// Get object of Contacts folder.
Outlook.MAPIFolder contacts = ns.

GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

items = contacts.Items;

items.ItemChange += new
Outlook.ItemsEvents_ItemChangeEventHandler(
this.Items_ItemChange);

items.ItemAdd += new
Outlook.ItemsEvents_ItemAddEventHandler(
this.Items_ItemAdd);

Now, Whenever any new Contact added to Outlook I assigned it a new
UserProperty of unique ID, to save this ID I have to call function

ContactItem.Save()

Without this any change doesn't save/remain in that contact.

As soon as the ContactItem.Save() executes
Sometimes it raises the events:

Outlook.ItemsEvents_ItemChangeEventHandler(CallFunc);

or

ItemsEvents_ItemAddEventHandler(CallFunc);

and this behaviour is not consistent, some time these events
raises continously and soem other day not.

I want to ask:

1. Why this event raises??
2. If this raises event then why it doesn't consistent??
3. Is their anyway I could skip or unregister this event??

Thanks In Advance!
 
S

Sue Mosher [MVP-Outlook]

I have a problem related to ContactItem. Save().
I am using VS2005 C# with MSOffice2003 outlook.

I am working on a AddIn for Outlook.

As my Addin load in application start function. I call a function that
register following two events:

// Get object of Contacts folder.
Outlook.MAPIFolder contacts = ns.

GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

items = contacts.Items;

items.ItemChange += new
Outlook.ItemsEvents_ItemChangeEventHandler(
this.Items_ItemChange);

items.ItemAdd += new
Outlook.ItemsEvents_ItemAddEventHandler(
this.Items_ItemAdd);

Now, Whenever any new Contact added to Outlook I assigned it a new
UserProperty of unique ID, to save this ID I have to call function

ContactItem.Save()

Without this any change doesn't save/remain in that contact.

As soon as the ContactItem.Save() executes
Sometimes it raises the events:

Outlook.ItemsEvents_ItemChangeEventHandler(CallFunc);

or

ItemsEvents_ItemAddEventHandler(CallFunc);

and this behaviour is not consistent, some time these events
raises continously and soem other day not.

I want to ask:

1. Why this event raises??

ItemChange fires because you're saving changes to an item.
2. If this raises event then why it doesn't consistent??

Maybe your code is running too fast? The underlying architecture doesn't fire the event if more than 16 items are changed at once. Or maybe you don't have items declared at the module level and the garbage collector is releasing it, so your event handlers no longer run.
3. Is their anyway I could skip or unregister this event??

I'm not a C# programmer, but I know it has a syntax for unregistering an event handler.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top