ItemChange Event to Propagate Contacts

C

C. Collings

Hi,

I am trying to use the ItemChange event on Contacts.Items to execute VBA
code that will propagate the change to a contacts folder in my local PST file.

My question is two-part:
1. When I delete a contactitem from the contacts folder, the ItemChange
event fires and copies the deleted item to my PST file. How can I
distinguish the difference between changing an item or deleting an item using
VBA? If I also add code for the ItemRemove Event, will both events still
fire?

2. When I manually copy a contactitem from one folder to another it asks if
I want to update with changes or copy as a new item? When I propagate a
changed item using VBA, it adds the changed item as a new item rather than
merging the changed item with the existing item and doesn't give me an
option? Is there something I can do differently?

Sub ContactsFolder_ItemChange(ByVal Item As Object)
If InStr(Item.Categories, "Keyword") > 0 Then
Dim Destination_Folder As MAPIFolder
Set Destination_Folder = GetFolder("Mailbox - Keyword\Contacts")
Set ContactItemCopy = Item.Copy
ContactItemCopy.Move Destination_Folder
Else
Set Destination_Folder = GetFolder("Mailbox - Local\Contacts")
Set ContactItemCopy = Item.Copy
ContactItemCopy.Move Destination_Folder
End If
End Sub

Thanks,
Collings
 
D

Dmitry Streblechenko

1. I do not see ItemChange event firing whe na contact is deleted., no
matter whether I simply hit Delete or Shift+Delete. What do you see in
OutlookSpy (url below) if you go to the Contacts fodler, click Folde rbutton
on the OutlookSpy toolbar, select the Items property, click Browsse.
In the Items window, go to the Events tab. Now delete a contact. What do do
you see in the log?
2. Outlook performs the duplicate check only when you add a contact through
the UI. If you go through the Object Model, it never checks for duplicates
(not should it IMHO). Any duplicate checks are your reponsibility.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

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