Synchronisation API for Contacts

May 19, 2008 at 12:26 AM
I am busy writing an application which synchronised contacts for Vista. I found the C4F ContactAPI which wraps the iContactsAPI. However it doesn't offer me several features I would like, such as :

- Ability to assign GUIDs to newly created contacts, rather then letting the GUIDs be generated

- Import / Merge vCards mode. When importing vCard, duplicates are happily imported. A exception when duplicates are encountered / merged. Some option to handle this, other then just creating 2 contacts.

- Find Contacts by GUIDs. I think this is supported but wasn't able to test it.

- Find Contacts by name, firstname, phone or email.

I am thinking that useing the ActiveSync API would be a better option, however I am not sure there is an C# wrapper for the Active Sync API. Any suggestions on what API would be best suited for this are welcome. Ideally I would like to develop within .Net / C# and not use lower level C++ API's.

Thanks in advance

Jun 17, 2008 at 4:22 PM
You can replace the auto-generated GUID on a contact with
contact.ContactIds.Default = new Guid(...);
The default just gets generated because there always needs to be at least one GUID.

You can also find the contacts by those guids.  The parameter in ContactManager.GetContact() is a string of the format "/GUID:\"<your-guid-here>\".  There's also an optional "/PATH:" part.  This is the same string that you'll get from the Contact.Id property.

Duplicate detection and merge aren't done.  Nor is there a first-class search API, but you can use LINQ since ContactManager.GetContactCollection supports IEnumerable<Contact>.  These are things I'd like to do but haven't yet.  I don't know of any plans to update the C4F dev kit beyond this initial release.  The contacts stuff was based on a snapshot of another codeplex project Contacts.Net that has been updated since and might work better for what you want.  Though C4F did add some things like the SimpleContact view and the services.

Hope that helps,