Export (0) Print
Expand All

How to: Add Context to an Outbound Conversation

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

This topic shows how to add context to an instant messaging (IM) conversation by using .NET Framework managed code with Microsoft Lync 2013 Preview SDK.

This walkthrough uses the Silverlight Application template. It uses the AutomationModalitySettings enumeration to specify the application ID and the content of the context data, and uses the BeginStartConversation method to launch the conversation.

To create the contextual conversation application

  1. Sign in to Microsoft Lync 2013 Preview.

  2. In Microsoft Visual Studio development system, create a new application. The application can be any kind of managed code application. In this procedure, use the Silverlight Application template to create the application.

  3. Add a project reference to Microsoft.Lync.Model, and to Microsoft.Lync.Utilities. The default location is %ProgramFiles%\Microsoft Lync\SDK\Assemblies\WPF.

  4. In MainPage.xaml.cs, add the following using statements.

    using Microsoft.Lync.Model;
    using Microsoft.Lync.Model.Extensibility;
    
  5. In the MainPage constructor, after the InitializeComponent method, add the following code.

    LyncClient client;
    string appID = “insert your application GUID here”;
    
    client = LyncClient.GetClient();
    
    if (client.State != ClientState.SignedIn)
    {
        MessageBox.Show("Lync is not signed in!");
    }
    else
    {   
        // Create the major API automation object.
        Automation automation = 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>();
        inviteeList.Add("elise@contoso.com");
        
        // Create a generic Dictionary object to contain context objects.
        Dictionary<AutomationModalitySettings, object> _ModalitySettings = new Dictionary<AutomationModalitySettings, object>();
    
    
    
    
    
        // Specify the initial context data and the application ID.
        _ModalitySettings.Add(AutomationModalitySettings.ApplicationData, “your initial context data”);
        _ModalitySettings.Add(AutomationModalitySettings.ApplicationId, appID);
    
        // Start the conversation.
        IAsyncResult ar = automation.BeginStartConversation(
        AutomationModalities.InstantMessage
        , inviteeList
        , _ModalitySettings
        , null
        , null);
    
    
    
    }
    
  6. Register the application. Contextual data applications must be registered on each client included in the contextual conversation. For more information see Register Contextual Conversation Packages.

  7. Build and run the application.

  8. Use the GetApplicationData method to retrieve the initial context data on the client computer that receives the message.

Community Additions

Show:
© 2014 Microsoft