简体   繁体   English

从 C# Asp.net 向 Lync 发送消息

[英]Sending a message to Lync from C# Asp.net

I have a notification system for my Asp.net application that uses sql-server.我有一个使用 sql-server 的 Asp.net 应用程序的通知系统。 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?我想知道,是否有一种方法可以使用 Lync 而不是电子邮件,以便在表更新时,用户将收到 Lync 消息?

You can use Lync client for .Net.您可以将 Lync 客户端用于 .Net。 Here is the link- https://code.msdn.microsoft.com/lync/Lync-2013-Use-the-Lync-47ded7b4这是链接 - 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:receiver1@domain.com", "sip:receiver2@domain.com" }; //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)
    {

    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM