Friday, June 08, 2012 4:13 PM
I'd like to do some post-processing of an Outlook.ContactItem after I've created it and the Contact editor has been closed. I would like to be able to trap:
- User closes the contact editor (i.e. doesn't save it)
- User clicks 'Save and Close' for a new contact
- User clicks 'Save and Close' for a contact and Outlook finds one or more duplicates, and then two things can happen:
- User can choose to create a new contact
- User can update an existing contact - and there are two cases here:
- there were changes to merge in to the existing contact
- there were no changes to merge in to the existing contact
In 3.2 (duplicate found, 'update' picked), the updated contact is no longer the original contact I created and have a reference to.
I'm wondering if there are events I can trap or if there is anything in the Outlook.ContactItem I have a reference to that would tell me anything about its final disposition:
- saved as itself
- merged into another contact and that other contact was saved and if so, is a reference or ID for that other contact available anywhere
- not saved at all
Ideally, would like this for 2003, 2007 and 2010 in C#.
- Edited by DAC_NW Friday, June 08, 2012 4:47 PM Better title
Tuesday, June 12, 2012 8:43 AMModerator
Thank you for posting to MSDN Forum.
In accordance with your issue , I would suggest you some threads you were wondering respectively.
- saved as itself—it's suggested that you can use the ContactItem.BeforeAutoSave event,which occurs before the item is automatically saved by Outlook.
- merged into anther duplicate contact—I think you will delete the duplicate contact and save the other one , so the ContactItem.BeforeDelete event can be used.
- not saved at all—as far as I know, there is no event to be used. However, you can try the ContactItem.Saved property.If you modify the contact after create it , the Saved property will have been False until the contact is saved.
If I misunderstand you, please feel free to let me know so that I can improve my answers .
MSDN Community Support | Feedback to us
Tuesday, June 12, 2012 3:38 PM
Thanks for the suggestions. Unfortunately, the events don't get fired in all scenarios:
- Not sure when BeforeAutoSave gets fired, but I couldn't get it to do so in my testing ('Save and Close' button, ctrl-S, etc.). I can use the 'Write' event to trap this, as long as the contact is saved as a new contact (vs being merged into an existing contact).
- BeforeDelete doesn't get fired. My new contact has not yet been saved, so this probably doesn't get fired. If I save it before displaying it, then Outlook's duplicate detection dialog doesn't get invoked.
- Saved property will tell me if the contact I started with has been saved (i.e. saved as a new contact) - but it doesn't tell me if the contact was merged into another contact, and the merged contact saved.
Wednesday, June 13, 2012 3:52 PMModerator
The other option (if this is an in-house solution) would be to disable the built-in duplicate contact detection altogether. Theoretically, and optionally, your add-in could provide this functionality itself (and thus have full control over things). But of course that's a lot of work to implement.
I'm sorry there isn't a better answer here, at least that I'm aware of.
Bill Jacob - Microsoft Customer Service & Support - Developer Messaging
- Marked As Answer by DAC_NW Wednesday, June 13, 2012 4:10 PM
Wednesday, June 13, 2012 4:10 PM
Thanks for the suggestions. I've implemented some event handlers to trap everything I can think of when a 'save' is done ('Save and Close', 'File - Save', 'File - Save and New', CTRL-S, etc.) so I can tell when the item is saved. I can then check the EntityID of my original contact - if the item was saved and the EntityID is not set, then I know the user merged the data into an existing contact.
The only bit missing is how to get the ID of that merge contact - I'll try your suggestion of searching.
I'm not keen on implementing my own duplicate detection...