ContactItem.Save()

V

Virda

problem is whatever change is made in Contact folder's Contact Item I
capture the event 'ItemChange' and process that contactItem.

In Contact Item Add event there is a need of my program to send data to
server of perticular Contact Item after update the data I want to save it by
using ContactItem.Save().

But, as soon as ContactItem.Save() function executed it raises the event
ContactItemChanged.

Due to this behaviour multiple times same data send to server.

Is there any way I could prevent this behaviour?

I am looking forward your answer.
 
K

Ken Slovak - [MVP - Outlook]

Look at the LastModificationTime property on the item. Use some sort of time
comparison so that unless a change hasn't occurred in x seconds or minutes
you don't synch the item. Something like that is about all you can do.
 
V

Virda

Hello Ken,

Thanks for your reply!

I tried your recomended solution but it didn't work.

Acutually during Sync/receiving all items from server I have to add into the
Outlook 2003 along with a userproperty where we save its ID.

After it I ahve to call ContactItem.Save().

As soon as this save() functin executed the ItemsEvents_ItemAddEventHandler
evevt raises and inside this event handler we are sending this perticular
item to server. Due to this cycle same data resend to server, that is wrong.

IS there a way Icould disable this event or remove this event???
 
K

Ken Slovak - [MVP - Outlook]

I suppose you could remove whatever class you're using to handle the
ItemAdd/Change events and then re-instantiate it after doing your synching.
Of course anything changed/added during that time would not be picked up
then.
 
V

Virda

Thanks a lot Ken Slovak

I think you are right but problem then How can I get the event from Outlook
whenever user add/edit/delete any Contact/Task/Calendar item.

Currectly I registered these calsses at ThisApplication_Startup.
 
V

Virda

:

Thanks a lot Ken Slovak

I think you are right but problem is if I disable all these events then
How can I get the event from Outlook in that case
whenever user add/edit/delete any Contact/Task/Calendar item.

Currectly I registered these calsses at ThisApplication_Startup.

To get the any change related to Outlook Contact/Task/Calendar.

Should I make the instances of these classes global and then reinitialize

all these classes after sync process??
 
K

Ken Slovak - [MVP - Outlook]

I'd probably create a global collection to gather all my event handling
classes and keep them alive and then remove those collection members as they
aren't needed or you need to de-reference them. Then I'd create a new class
instance to handle the events and add it to the collection.

Say on start synch you get rid of the class. Then on end of synch you
instantiate a new instance. That would work.
 
V

Virda

Thanks a lot Ken Slovak,

Now the sync problem has removed the instantiate and uninstantiation logic
of classes worked. But I didn't make the collecion.

Now the problem is all my classes related to conact/task/calendar/ are
instantiated in Application_start() of Addin.

Wo, whenever I receive Contact add event I made changes to it and call
ContactItem.Save(). by doing this the item_change event is raising

If I unregister the event using

items.ItemChange -= new Outlook.ItemsEvents_ItemChangeEventHandler(Func);

then this event perminently removed.

How could I overcome this problem, for the time being I used bool variables
tok handle this situation.

Also, Another problem is whenever birthday field set in contact item.
the new activity added in calendar I want to remove this activity or it
should not be added to calendar folder.

If I try to remove it inside Contact item add evet, then at that time this
activity not cteated.

Thanks a lot again your kind cooperation and on time answers.
 
K

Ken Slovak - [MVP - Outlook]

Can't you re-add your event handlers using the += syntax when you are
finished with your synch? Are the flags you're now using not working? If
they are just keep using them.

I'd probably not remove the event handlers but simply set a flag that says
an update/move operation is in progress. If that flag is set then just exit
the OnChange event without doing anything.

If you remove the birthday setting by setting the date to None (1/1/4501) no
reminder will be created and no recurring appointment for that birthday will
be created. The same will apply to Anniversary. After the move you can then
re-set the birthday/anniversary property as needed from your stored values
and then handle the creation of the recurring appointments.
 
P

Pramod

hi vird,

I too have the same problem,the only difference is that you are inserting or sending the record in sqlserver and i am creating an xml file in itemChange.

You said that you have controlled the multiple file creation using flag.If u can share the information with me about how you set the flag.that will be usefull for me.

in my case both itemchange and explorer change is firing contiuosly after editing or modifying.

pramod

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 

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