Export (0) Print
Expand All

Lync 2013 Preview SDK Development Models

[This is preliminary documentation and is subject to change.]

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

To add Lync 2013 Preview 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 2013 Preview API features into your application.

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

You can drag and drop Microsoft Lync Controls into existing business applications to add Lync 2013 Preview 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 2013 Preview 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 2013 Preview API and .NET Framework. For more information, see Lync 2013 Preview 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 2013 Preview functionality to Silverlight 4 browser applications.

  • Add Lync 2013 Preview 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 How to: Publish Presence.

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

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


Use Lync 2013 Preview API to launch and automate the Lync 2013 Preview 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 2013 Preview API in Lync SDK. For more information, see How to: Start an Instant Message Conversation.

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, object>();
  myContextObjects.Add(AutomationModalitySettings.FirstInstantMessage, "hello");
  myContextObjects.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);

  // Start the conversation.
  IAsyncResult ar = myUIAuto.BeginStartConversation(AutomationModalities.InstantMessage, inviteeList, myContextObjects,   null, null);

Advanced Application Scenarios

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

The only UI element that Lync 2013 Preview 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 2013 Preview 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 2013 Preview.

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 How to: Display a Contact Card.

private void ContactCardForm_Load(object sender, EventArgs e)
    Contact myContact = sender as Contact;
    if (myContact != null)
        this.Text = "Contact: " + myContact.GetContactInformation(ContactInformationType.Name).ToString();
        lbl_EmailValue.Text = myContact.GetContactInformation(ContactInformationType.PrimaryEmail).ToString();
        List<object> contactPhones = null;
        contactPhones = (List<object>) myContact.GetContactInformation(ContactInformationType.CollaborationEndpoints);

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

        lbl_TitleValue.Text = myContact.GetContactInformation(ContactInformationType.Title).ToString();
        lbl_OfficeValue.Text = myContact.GetContactInformation(ContactInformationType.Office).ToString();


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

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

           LyncClient.GetClient().ClientStateChanged += myClient_ClientStateChanged;


                IAsyncResult ar = LyncClient.GetClient().BeginSignIn(

            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");

OCOM Unmanaged COM API

Use the Lync 2010 API Reference to learn about the unmanaged Office Communicator Object Model API (OCOM). The OCOM API contains a subset of the types that are in the Lync 2013 Preview API. You cannot start or carry on conversations with OCOM, but you can access a contact list and get contact presence.

It is not recommended that you use this API, but if you are a C++ developer and you need to add contact and presence features to your application, then this API can work for you.

Community Additions

© 2014 Microsoft