我有一个VBA,添加到我的Outlook,它通过Lync发送消息.脚本如下所示.
Sub sendIM(toUsers As Variant, message As String)
Dim msgr As CommunicatorAPI.IMessengerConversationWndAdvanced
'Open messenger window and send message!!!!!
Set msgr = messenger.InstantMessage(toUsers)
msgr.SendText (message)
Set msgr = Nothing
Run Code Online (Sandbox Code Playgroud)
它工作正常.如果有10个用户,则在toUsers变量中,它将消息作为"组"发送给所有用户.
我想要的是,如果有用户离线,我想得到一些通知,说明该人不在线.Messenger显示"错误",说"无法邀请"n"人们加入会议".
我可以获得一些状态,该状态会返回所有未发送消息的用户的详细信息吗?
你正在以错误的方式解决这个问题......不是创建你的通讯组列表然后查找异常,而是查看谁在线并将消息发送给那些人.
以下两个函数将返回所有Lync联系人的数组及其当前状态.使用该数组来定位包含在邮件中的人员.
Function LyncContactsStatus() As Variant
Dim appLync As CommunicatorAPI.Messenger
Dim LyncDirectory As CommunicatorAPI.IMessengerContacts
Dim LyncContact As CommunicatorAPI.IMessengerContact
Dim arrContacts() As Variant
Dim lngLoopCount As Long
Set appLync = CreateObject("Communicator.UIAutomation")
appLync.AutoSignin
Set LyncDirectory = appLync.MyContacts
ReDim arrContacts(LyncDirectory.Count - 1, 1)
For lngLoopCount = 0 To LyncDirectory.Count - 1
Set LyncContact = LyncDirectory.Item(lngLoopCount)
arrContacts(lngLoopCount, 0) = LyncContact.FriendlyName
arrContacts(lngLoopCount, 1) = LyncStatus(LyncContact.Status)
Next lngLoopCount
LyncContactsStatus = arrContacts
Set appLync = Nothing
End Function
Function LyncStatus(IntStatus As Integer) As String
Select Case IntStatus
Case 1 'MISTATUS_OFFLINE
LyncStatus = "Offline"
Case 2 'MISTATUS_ONLINE
LyncStatus = "Online"
Case 6 'MISTATUS_INVISIBLE
LyncStatus = "Invisible"
Case 10 'MISTATUS_BUSY
LyncStatus = "Busy"
Case 14 'MISTATUS_BE_RIGHT_BACK
LyncStatus = "Be Right Back"
Case 18 'MISTATUS_IDLE
LyncStatus = "Idle"
Case 34 'MISTATUS_AWAY
LyncStatus = "Away"
Case 50 'MISTATUS_ON_THE_PHONE
LyncStatus = "On the Phone"
Case 66 'MISTATUS_OUT_TO_LUNCH
LyncStatus = "Out to Lunch"
Case 82 'MISTATUS_IN_A_MEETING
LyncStatus = "In a meeting"
Case 98 'MISTATUS_OUT_OF_OFFICE
LyncStatus = "Out of office"
Case 114 'MISTATUS_OUT_OF_OFFICE
LyncStatus = "Do not disturb"
Case 130 'MISTATUS_IN_A_CONFERENCE
LyncStatus = "In a conference"
Case Else
LyncStatus = "Unknown"
End Select
End Function
Run Code Online (Sandbox Code Playgroud)