使用 VBA 的离线人员的 Lync 通知
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14192417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Lync notification of offline people using VBA
提问by hari
I am having a VBA, Added to my outlook, which sends message over Lync. The Script is as given below.
我有一个 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
It works fine. If there are 10 users, in the toUsers variable, then it sends the message to all as a "Group".
它工作正常。如果在 toUsers 变量中有 10 个用户,那么它会将消息作为“组”发送给所有人。
What i want is, if there is a user who is offline, I would like to get some notification that the person is not online. The Messenger displays "Error", saying "Cannot invite "n" people to join the meeting".
我想要的是,如果有一个用户离线,我想收到一些关于此人不在线的通知。Messenger 显示“错误”,说“无法邀请“n”个人加入会议”。
Can I get some status, which returns me details of all the users, whom the message was not sent?
我可以得到一些状态,返回所有用户的详细信息,消息没有发送给我吗?
回答by FillsTubs
You're going about this the wrong way... Rather than creating your distribution list and then looking for exceptions, look to see who is online and send the message to just those folks.
您正在以错误的方式处理此问题...与其创建分发列表然后查找例外情况,不如查看谁在线并将消息发送给那些人。
The following two functions will return an array of all your Lync contacts with their current status. Use the array to target who gets included in your message.
以下两个函数将返回所有 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