Use Microsoft Lync 2010 SDK to add communications and collaboration functionality to your application. With Lync SDK, you can add Microsoft Lync 2010 features to an existing business application, or create a custom client that includes Microsoft Lync 2010 features. In either case, Lync 2010 must be a running process on the client computer that hosts a Microsoft Lync 2010 API application.

To add Lync 2010 features to an application, you drag and drop XAML controls from the Lync SDK into a Microsoft Windows Presentation Foundation (WPF) or Microsoft Silverlight application. For more advanced scenarios, use a .NET Framework language to incorporate Lync 2010 API features into your application.

Lync 2010 API is commonly used to start a new conversation within your custom application, after which you'll participate in that conversation using the Lync 2010 conversation window. You can also start and participate in a conversation within your custom application without displaying the Lync 2010 conversation window. Lync 2010 API can also be used to generate a contact list within your custom application using data obtained from Lync 2010.

Lync Controls

You can drag and drop Microsoft Lync Controls into existing business applications to add Lync 2010 functions and user interface. Each Lync Control provides a specific feature like search, presence, instant messaging (IM) calls, and audio calls. The appearance of each control replicates the Lync 2010 UI for that feature. Use a single control or multiple controls. The programming style is primarily XAML text, but you can also use C# in the code-behind file to access the Lync 2010 API and .NET Framework. For more information, see Lync Controls .

Lync Controls Application Scenarios

  • Drag and drop the PresenceIndicator control into each application, then set property values to configure how the control displays presence and contact information.

  • Add Lync 2010 functionality to Silverlight 4 browser applications.

  • Add Lync 2010 capabilities to .NET Framework applications using WPF.

Lync Controls Code Example

The following XAML text displays a PresenceIndicator control in a Lync Controls application. For more information, see Walkthrough: Presence Hello World .

XAML  Copy imageCopy Code
<Window x:Class="myWpfApplication.UCWindow1"
	Title="UCWindow1" Height="Auto" Width="Auto">
		<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center" VerticalAlignment="Center">

				Text="{Binding DisplayName, ElementName=Presence}" 


Lync API

Use Lync 2010 API to launch and automate the Lync 2010 UI in your business application. Use Lync Controls to integrate specific features like presence, contact cards, or search, in a business application.

Lync API Application Scenarios

  • Start an instant messaging or audio conversation from a custom application.

  • Join or start a conference.

  • Add a new contact to your contact list.

Start Conversation Code Example

The following example starts an IM conversation using Lync 2010 API in Lync SDK. For more information, see Walkthrough: Start an Instant Message Conversation .

C#  Copy imageCopy Code
public Form1()
  // Create the major API automation object.
  Automation myUIAuto = LyncClient.GetAutomation();

  // Create a generic List object to contain a contact URI.
  // Ensure that a valid URI is added.
  List<string> inviteeList = new List<string>();

  // Create a generic Dictionary object to contain context objects.
  Dictionary<AutomationModalitySettings, object>
myContextObjects = new Dictionary<AutomationModalitySettings,

  // Start the conversation.
  IAsyncResult ar =
inviteeList, myContextObjects,   null, null);

Advanced Application Scenarios

Use Lync 2010 API to add Lync 2010 functionality to new or existing .NET Framework applications and suppress the Lync 2010 UI. Lync SDK UI Automation automates the Lync 2010 interface, and Lync Controls add separate pieces of Lync 2010 functionality and UI as XAML controls. For more information, see Lync 2010 API .

The only UI element that Lync 2010 API exposes is the Microsoft.Lync.Model.Conversation.AudioVideo . . :: . . VideoWindow class. All other classes expose methods you call or properties you can read to update your own application UI. Using the advanced API features, you are responsible for writing more complex application logic around the API calls. This approach gives you a degree of flexibility to customize the look and feel of a client collaboration application.

Before you develop applications with Lync 2010 API, you should be familiar with the .NET Framework asynchronous programming pattern. You will write event handling methods and asynchronous callback methods to catch the results of operations and notifications of new and changed information from Lync Server 2010.

Lync API Application Scenarios

  • Contact management, availability publication and contact information, fill group and contact lists, search for groups and contacts, query contact availability and contact information.

  • Start or join IM, audio, and video conversations, add conversation participants, park and reactivate conversations, schedule and join conferences.

Lync API Code Example

The following example collects contact information. For more information, see Walkthrough: Display a Contact Card .

C#  Copy imageCopy Code
private void ContactCardForm_Load(object sender, EventArgs e)
	Contact myContact = sender as Contact;
	if (myContact != null)
		this.Text = "Contact: " +
		lbl_EmailValue.Text =
		List<object> contactPhones = null;
		contactPhones = (List<object>)

		foreach (object o in contactPhones)
			CollaborationEndpoint collabEndpoint = o as
			switch (collabEndpoint.Type)
				case CollaborationEndpointType.Home:
					lbl_HomeValue.Text =
				case CollaborationEndpointType.Mobile:
					lbl_MobileValue.Text =
				case CollaborationEndpointType.Work:
					lbl_WorkValue.Text =

		lbl_TitleValue.Text =
		lbl_OfficeValue.Text =


The following example signs in to Lync Server 2010 and handles the asynchronous results of a sign in request. For more information, see Walkthrough: Sign In to Lync .

C#  Copy imageCopy Code
		/// <summary>
		/// Method to sign in to Lync
		/// </summary>
		/// <param name="UserUri">string. Uri of
		/// <param name="Domain">string. User name and Domain
of user.</param>
		/// <param name="Password">string. Password of
		public void SignIn(string UserUri, string UserNameDomain,
string Password)

		 LyncClient.GetClient().ClientStateChanged +=


				IAsyncResult ar =

			catch (NotInitializedException)
			 MessageBox.Show("Lync is not initialized");

		/// <summary>
		/// Handles LyncClient state change events. 
		/// </summary>
		/// <param name="source">LyncClient.  Client source
of events.</param>
		/// <param name="data">ClientStateChangedEventArgs.
State change data.</param>
		void myClient_ClientStateChanged(object source,
ClientStateChangedEventArgs data)
			if (data.NewState == ClientState.SignedIn)
				MessageBox.Show("Signed in");
			if (data.NewState == ClientState.SignedOut)
				MessageBox.Show("Signed out");

			if (data.NewState == ClientState.ShuttingDown )
				MessageBox.Show("Client is shutting down");

See Also