Bridge Communications

Monday, November 10, 2014

Getting Lync Contact Information

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;

LyncClient lc;
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:someone@somedomain.com and it returns us a contact object.

Contact c = lc.ContactManager.GetContactByUri("sip:someone@somedomain.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;

(string)c.GetContactInformation(ContactInformationType.DisplayName);

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;

Activity
Availability
Capabilities
Company
ContactEnpoints (like mobile number, voicemail id, etc)
Default Note
Department
Description
EmailAddress
FirstName
LastName
Title
Photo
...

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





No comments:

Post a Comment