This topic demonstrates how to display the contact information types published by a user represented by Contact . The displayed information can be thought of as a contact card. A Contact exposes two types of property collections.

  • Contact Information: Read only. Contact information types are published by a local user for all other users to access according to established privacy relationships. Because of privacy relationship restrictions, a local user may not be able to access a contact information value published by a remote contact. When this happens, a call into GetContactInformation returns a null value when type requested is not available. For more information about privacy relationships, see Walkthrough: Change the Privacy Relationship of a Contact .

  • Contact Settings: Read/Write. The settings choices for a contact are made by the local user and affect interaction with other users individually. For example: The local user John has added Mark to his contact list. John chooses the access level setting of "Workgroup" for the Mark's contact instance. With this choice, John has given Mark access to his published contact information where appropriate for a member of John's workgroup. Susan has also added Mark to her contact list but because Susan is in a different workgroup, she chose the access level setting of "Colleague" for Mark's contact instance. Mark can now see Susan's published contact information where appropriate for a member of the same enterprise.

This walkthrough demonstrates how your code accesses contact information after subscribing to a contact.

Displaying a Contact Card

  1. Get the LyncClient instance. Verify that the client is signed in to the server. For information about signing in to Microsoft Lync Server 2010, see Walkthrough: Sign In to Lync .

  2. Get a Contactinstance. For information about searching for a contact or distribution group, see Walkthrough: Search For a Contact .

  3. Call the GetContactInformation method on the Contactinstance. This call can include use of the ContactInformationType enumeration to obtain specific contact card information and the ContactEndpointType enumeration to determine the type of instances of the ContactEndpoint class found in the collection of contact telephone numbers.


The following example shows an override of the ToStringmethod on an application class that encapsulates a Contact instance. If a contact was identified to be detailed, this method collects the contact's name, primary e-mail address, all phone numbers, title, and office using calls to the GetContactInformation method. If a distribution group was identified to be detailed, this method collects the group's name.

C#  Copy imageCopy Code
		/// <summary>
		/// Overrides the ToString() method allowing an instance of
ContactModel to be added to a UI element that
		/// calls ToString() on this object.
		/// </summary>
		/// <returns>string. A set of contact information
		public override string ToString()
			string returnValue = string.Empty;
			string activityDescription = null;
			List<object> collaborationPhones = null;

			activityDescription =
			collaborationPhones =

			if (collaborationPhones != null)
				returnValue += "\r\nPhones:";
				foreach (object phone in collaborationPhones)
					ContactEndpoint anEndpoint =
					returnValue += "\r\nType: "
						+ anEndpoint.Type.ToString()
						+ " DisplayName: "
						+ anEndpoint.DisplayName
						+ " Uri: "
						+ anEndpoint.Uri;


			returnValue += activityDescription;
			returnValue += "\r\nPersonal note: " +
			returnValue += "\r\nOOF note: " +

			return returnValue;

See Also