Search code examples
c#lynclync-2013lync-client-sdk

How to retrieve IM message from lync client 2013 communication


I am using lync 2013 sdk and i need to create a task with conversation IM message on the end of call.

I want some method as - conversation.getIMmessage() etc.

how can i implement that.


Solution

  • So assuming you are using the Lync Client SDK you are going to need to add an event handler for IM received to the IM modality of each participant in a conversation. This is best considered in reverse order:-

    Set up an event handler for participant being added to a conversation:-

    Conversation.ParticipantAdded += Conversation_ParticipantAdded;
    

    In that event handler get the IM Modality for that participant, with something like:-

    var imModality = Conversation.Participants.Single(p => p.Contact.Uri.Equals(newParticipantSIP, StringComparison.CurrentCultureIgnoreCase)).Modalities[ModalityTypes.InstantMessage] as InstantMessageModality;
    

    And then add a IM received event handler to the modality:-

    imModality.InstantMessageReceived += (sender, e) =>
                    {
                        DoStuff(e.Text);
                    };