Lync 二次開發-對單個聯絡人和聯繫人組發送即時消息

對單個聯繫人發送消息此方法只是彈出聯繫人聊天對話框(對方在線時),並沒有發送出消息      

[ScriptableMember]
        public void CallSingleMsg(string sipUri)
        {
            var lyncAutomation = LyncClient.GetAutomation();

            var inviteeList = new string[] { sipUri };
            var modalitySettings = new Dictionary();
            modalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, false);
            if (string.IsNullOrEmpty(""))
            {
                modalitySettings.Add(AutomationModalitySettings.Subject, "");
            }

            lyncAutomation.BeginStartConversation(
                AutomationModalities.InstantMessage,
                inviteeList,
                modalitySettings,
                (ar) => { if (ar.IsCompleted) { ((Automation)ar.AsyncState).EndStartConversation(ar); } },
                lyncAutomation);

        }

 

對通訊組發送即時消息

[ScriptableMember]
        public void CallGroupMsg(string sipUri)
        {
            LyncClient client = LyncClient.GetClient();
            Automation lyncAutomation = LyncClient.GetAutomation();
            List inviteeList = new List();
            InstantMessageModality m = null;
            Conversation conversation = conversation = client.ConversationManager.AddConversation();

            //異步查詢出聯繫人取出sipuri 添加到sip地址集合
            client.ContactManager.BeginLookup(sipUri, (ir) =>
            {
                try
                {
                    object foundItem = client.ContactManager.EndLookup(ir);
                    if (foundItem.GetType().Name == "DistributionGroup")
                    {
                        Group foundGroup = foundItem as Group;
                        foreach (var item in foundGroup)
                        {
                            inviteeList.Add(item.Uri);
                        }
              

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章