Asked by:
SendFirstInstantMessageImmediately Not working....

Question
-
Have the following code
Initiatites a meeting. But no message sent.
BTW can manually send messages just fine.
/=================
private void Button_Click(object sender, RoutedEventArgs e)
{
Automation automation = LyncClient.GetAutomation();
List<string> inviteeList = new List<string>();
Dictionary<AutomationModalitySettings, object> contextObjects = new Dictionary<AutomationModalitySettings, object>();inviteeList.Add("sip:abc@def.com");
contextObjects.Add(AutomationModalitySettings.FirstInstantMessage, "test message");
contextObjects.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);
automation.BeginStartConversation(
AutomationModalities.InstantMessage
, inviteeList
, contextObjects
, (ar) =>
{
if (ar.IsCompleted == true)
{
cWindow = automation.EndStartConversation(ar);
}
}
, automation);
}}
Saturday, April 4, 2015 6:07 PM
All replies
-
I have exactly the same issue. Did you manage to get this to work?
Wednesday, May 6, 2015 2:51 PM -
No I couldn't get it workThursday, May 21, 2015 8:57 PM
-
If you only want to send a msg to one person, I have it working in Visual Studio 2013.
The org code came from Code project Author Michael Rosqvist.
Option Explicit On Option Strict On Imports Microsoft.Lync.Model Imports Microsoft.Lync.Model.Conversation Imports System.DirectoryServices Imports System.DirectoryServices.AccountManagement Imports System.Text Imports System.Reflection Public Class frmMain Private ReadOnly gMessage As String = "Test Msg" Private gClient As LyncClient Private gConversation As Conversation Private gContact As Contact Private gParticipiant As Participant Private gSearchIsFinished As Boolean = False Private Sub btnGo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGo.Click 'get Lync id Dim LyncUri As String = String.Empty LyncUri = ("sip:someone@somesite.com") 'get a grab of the Lync client process gClient = LyncClient.GetClient() 'start looking for the Lync message receiver gClient.ContactManager.BeginSearch(LyncUri, SearchProviders.GlobalAddressList, SearchFields.EmailAddresses, SearchOptions.IncludeContactsWithoutSipOrTelUri, 1, AddressOf SearchCallback, New Object() {gClient.ContactManager, LyncUri}) 'wait for the callback to finish While Not gSearchIsFinished System.Threading.Thread.Sleep(500) End While 'add a conversation gConversation = gClient.ConversationManager.AddConversation() 'add the new message receiver gParticipiant = gConversation.AddParticipant(gContact) 'gParticipiant = AddParticipant(gContact) 'start sending the message Dim modal = DirectCast(gConversation.Modalities(ModalityTypes.InstantMessage), InstantMessageModality) modal.BeginSendMessage(gMessage, AddressOf SendMessageCallback, Nothing) End Sub Private Sub SendMessageCallback(ByVal r As IAsyncResult) gClient = Nothing End Sub Private Sub SearchCallback(ByVal r As IAsyncResult) Dim asyncState As Object() = DirectCast(r.AsyncState, Object()) Dim cm As ContactManager = DirectCast(asyncState(0), ContactManager) gContact = Nothing Try Dim results As SearchResults = cm.EndSearch(r) gContact = results.Contacts(0) Catch se As SearchException MessageBox.Show(se.Reason.ToString()) End Try gSearchIsFinished = True End Sub End Class
- Edited by Rodney_Wilson Friday, May 29, 2015 5:52 AM
Friday, May 29, 2015 5:51 AM -
I'm still looking for an answer, but there's another post about it here, where I commented with a potential workaround.Monday, July 6, 2015 10:58 PM