Search code examples
lynclync-2013lync-client-sdk

How to read Lync 2013 IM message programmatically


I want to read the Lync IM chat conversation programmatically. As Lync Client stores its IM logs into the .HIST file. Does anyone know the format of the .HIST file or how to read this file?

I have also read that by using Lync SDK we can get the Lync IM chat conversation. http://blog.thoughtstuff.co.uk/2013/01/tracking-lync-conversations-in-code/ this blog tells about how to track Audio-Video Call conversation into code. Can anyone tell me how can I implement to read the IM chat conversation?


Solution

  • You can listen to InstantMessageRecieved event under PaticipantAdded event. Refer to below sample code:

      // Add ParticipantAdded event
      conversation.ParticipantAdded += this.Conversation_ParticipantAdded;
    
      private void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) {
        var instantMessageModality = e.Participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality;
        instantMessageModality.InstantMessageReceived += this.Participant_InstantMessageReceived;
      }
    
      private void Participant_InstantMessageReceived(object sender, MessageSentEventArgs e) {
        // Use e.Text to read the chat information
      }