У меня есть адрес электронной почты пользователя 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();
}
}
}
Снимок экрана Ссылка на большой снимок экрана: https://i.imgur.com/LMHEF.png
Как вы можете видеть на этом снимке экрана, моя программа на самом деле не работает, хотя я могу вручную найти контакт и отправить мгновенное сообщение.
Я также пытался использовать ContactManager.BeginSearch()
вместо ContactManager.GetContactByUri()
, но получил тот же результат (вы можете видеть на скриншоте): http://pastie.org/private/o9joyzvux4mkhzsjw1pioa