This walkthrough demonstrates how to use an install registration to register a default context application, and then display that application in the Extensibility Window. For more information about install registration, see Registering Contextual Conversation Packages .

Prerequisites

For a list of prerequisites, see Walkthrough: Start an Instant Message Conversation . In addition, install Internet Information Services on both the sending and receiving client computers.

Creating a Sample Context Application

The following procedure describes creating and installing a simple HTML page to represent a context application packaged in a conversation. In a production environment, substitute an application install procedure that places the application on the appropriate client computers. The context application must be installed on each sending and receiving client computer.

To create a simple HTML page

  1. On the sending and receiving clients, add a folder at the path Inetpub/wwwroot.

  2. Create a new .html file using the following HTML text.

      Copy imageCopy Code
    <html>
    <head>
    </head>
    <body>
    <p>text in an HTML paragraph element</p>
    </body>
    </html>
    
  3. Save the .html file to the folder created in the first step.

Adding Registry Entries

The following procedure describes using registry entries to register the context application with Microsoft Lync 2010. In a production environment, use a setup application or group policy to create these registry entries.

To register the application

  1. In Visual Studio, create a GUID for the context application. For more information, see the topic Create GUID (guidgen.exe).

  2. In the registry, at the path HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages, create a key containing the GUID created in the previous step. See the following example.

      Copy imageCopy Code
    {40499119-4860-45a6-9A7A-DC7A384D5670}
    
  3. Add the following subkey/value pairs under the GUID added in the previous step. The values in the bottom four rows are examples. Modify these values to make them appropriate for your circumstances.

    Subkey

    Type

    Value

    DefaultContextPackage

    REG_DWORD

    0

    ExtensibilityWindowSize

    REG_DWORD

    1

    ExternalURL

    REG_SZ

    http://contoso.com/Test/sample.html

    InternalURL

    REG_SZ

    http://localhost/Test/sample.html

    Name

    REG_SZ

    myContextApplication

Create the Messaging Application

The following procedure describes creating a sample application to launch a conversation.

To create the messaging application

  1. In the Visual Studio development system, create a new application. The application can be any type of managed code application. In this procedure you create a Microsoft Windows Forms application.

  2. Add a project reference to Microsoft.Lync.Model. The default location is %ProgramFiles%\Microsoft Lync\SDK\Assemblies\WPF.

  3. In Form1.cs add the following using statements.

      Copy imageCopy Code
    using Microsoft.Lync.Model;
    using Microsoft.Lync.Model.Extensibility;
    
  4. Add the following declaration to the Form class.

      Copy imageCopy Code
    ConversationWindow cWindow;
    
  5. Add the following code to the Form1 constructor following the InitializeComponent method.

      Copy imageCopy Code
    //Create an automation object.
    Automation myUIAuto = LyncClient.GetAutomation();
    
    //Conversation participant list.
    //Provide a value that is valid in your domain.
    List<string> inviteeList = new List<string>();
    inviteeList.Add("sip:elise@costoso.com");
    
    //Declare a Dictionary object to pass context data.
    Dictionary<AutomationModalitySettings, object>
    myContextObjects = new Dictionary<AutomationModalitySettings,
    object>();
    
    //Provide conversation context: first IM message.
    string firstIMText = "hello";
    myContextObjects.Add(AutomationModalitySettings.FirstInstantMessage,
    firstIMText);
    
    //Provide conversation context: send the message immediately.
    myContextObjects.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately,
    true);
    
    //Provide conversation context: set the application ID
    //of the registered application providing context.
    myContextObjects.Add(AutomationModalitySettings.ApplicationId,
    "{40499119-4B60-45a6-9A7A-DC7A384D5670}");
    
    //Begin the conversation.
    IAsyncResult beginconversation = myUIAuto.BeginStartConversation(
    AutomationModalities.InstantMessage
    , inviteeList
    , myContextObjects
    , BeginConversationCallBack
    , myUIAuto);
    
  6. Add the following method to the Form1 class.

      Copy imageCopy Code
    //Notify the Automation object and ConversationWindow
    //that the conversation is started.
    private void BeginConversationCallBack(IAsyncResult ar)
    {
      if (ar.IsCompleted == true)
      {
    	Automation _automation = ar.AsyncState as Automation;
    	cWindow = _automation.EndStartConversation(ar);
    	IAsyncResult OpenExtensibilityResult =
    cWindow.BeginOpenExtensibility("{40499119-4B60-45a6-9A7A-DC7A384D5670}",null,null);
    	cWindow.EndOpenExtensibility(OpenExtensibilityResult);
    
      }
    }
    
  7. Build and run the application.

  8. In the conversation window on the sending and receiving clients, see the extensibility pane appear containing the context application.

See Also

Other Resources