我有一个 Lync 用户的电子邮件地址,并想向他发送即时消息。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Lync.Model;
using Microsoft.Lync.Model.Conversation;
namespace Build_Server_Lync_Notifier
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Usage: bsln.exe <uri> <message>");
return;
}
LyncClient client = Microsoft.Lync.Model.LyncClient.GetClient();
Contact contact = client.ContactManager.GetContactByUri(args[0]);
Conversation conversation = client.ConversationManager.AddConversation();
conversation.AddParticipant(contact);
Dictionary<InstantMessageContentType, String> messages = new Dictionary<InstantMessageContentType, String>();
messages.Add(InstantMessageContentType.PlainText, args[1]);
InstantMessageModality m = (InstantMessageModality) conversation.Modalities[ModalityTypes.InstantMessage];
m.BeginSendMessage(messages, null, messages);
//Console.Read();
}
}
}
大屏幕截图 链接:http: //i.imgur.com/LMHEF.png
正如您在此屏幕截图中看到的那样,我的程序似乎并没有真正工作,即使我能够手动搜索联系人并手动发送即时消息。
我也尝试使用ContactManager.BeginSearch()
而不是ContactManager.GetContactByUri()
,但得到了相同的结果(您可以在屏幕截图中看到): http: //pastie.org/private/o9joyzvux4mkhzsjw1pioa