In this post we'll talk about using the Lync client sdk to get information from a contact. I am going to assume for this post that you have figured out how to add the proper references and hook to the existing Lync client in a fashion like this;
lc = LyncClient.GetClient();
Once we have that we are given the ability to access the contact manager. We can get Lync to kick us back all the contact details by calling a method named GetContactByURI(string uri) This is pretty self explanatory as we pass it a uri like sip:firstname.lastname@example.org and it returns us a contact object.
Contact c = lc.ContactManager.GetContactByUri("sip:email@example.com");
From here we can examine properties of the contact with ease. Since we have our contact object c, we will open the properties method on it, and expose this;
Since the code returns a type of object in this case I want to cast the name as a string value. Some of the other types of contact information we can gather are as follows;
ContactEnpoints (like mobile number, voicemail id, etc)
The full list is here http://msdn.microsoft.com/en-us/library/microsoft.lync.model.contactinformationtype_di_3_uc_ocs14mreflyncclnt(v=office.14).aspx
You can find these values in the Microsoft.Lync.Model namespace.
As always if you get stuck feel free to comment or ask for help.
Doug Routledge, C# Lync, SQL, Exchange, UC Developer