nPcomp
nPcomp

Reputation: 9833

Sending a message to Lync from C# Asp.net

I have a notification system for my Asp.net application that uses sql-server. Currently, when there is an update on certain tables email alert sent. I am wondering, if there is a way to use Lync instead of email so that when tables updated, users will get Lync messages?

Upvotes: 1

Views: 2157

Answers (1)

Souvik Ghosh
Souvik Ghosh

Reputation: 4606

You can use Lync client for .Net. Here is the link- https://code.msdn.microsoft.com/lync/Lync-2013-Use-the-Lync-47ded7b4

Below is a sample code.

using Microsoft.Lync.Model;
using Microsoft.Lync.Model.Conversation;

private static void SendMessage()
{
    try
    {
        string[] arrRecepients = { "sip:[email protected]", "sip:[email protected]" }; //add your recepients here
        LyncClient lyncClient = LyncClient.GetClient();
        Conversation conversation = lyncClient.ConversationManager.AddConversation();

        foreach (string recepient in arrRecepients)
        {
            conversation.AddParticipant(lyncClient.ContactManager.GetContactByUri(recepient));
        }
        InstantMessageModality imModality = conversation.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality;
        string message = GetNotification(); //use your existing notification logic here
        imModality.BeginSendMessage(message, null, null);
    }
    catch (Exception ex)
    {

    }
}

Upvotes: 1

Related Questions