Lync 2013 SDK GetContactInformation 图片

Lync 2013 SDK GetContactInformation Photo

我目前正在尝试在我的应用程序中显示 Lync 用户的联系人图片。效果很好,但前提是之前在 Lync 客户端中查找过用户。似乎需要某种缓存。之前没有查找或没有将用户作为联系人列表中的直接联系人,它 returns 什么都没有。任何想法如何通过代码进行查找?这就是我现在正在做的事情:

Public Function GetLyncPicture(lyncMail As String) As Image
    Dim myimage As Image = Nothing

    Try
        If lyncMail.Trim.Length > 0 Then
            client = LyncClient.GetClient()

            If client IsNot Nothing Then
                Dim cManager As ContactManager = client.ContactManager

                If cManager IsNot Nothing Then
                    Dim contact As Contact = cManager.GetContactByUri(lyncMail)
                    If contact IsNot Nothing Then
                        Dim ciList As New List(Of ContactInformationType)()
                        ciList.Add(ContactInformationType.Photo)
                        Dim dic As IDictionary(Of ContactInformationType, Object) = Nothing
                        dic = contact.GetContactInformation(ciList)

                        If dic IsNot Nothing Then
                            Dim photoStream As Stream = TryCast(dic(ContactInformationType.Photo), Stream)

                            If photoStream IsNot Nothing Then
                                myimage = Image.FromStream(photoStream)
                            End If
                        End If
                    End If
                End If
            End If
        End If
    Catch ex As Exception
    End Try

    GetLyncPicture = myimage
End Function

您正在寻找的是ContactSubscription. For every contact you wish to see the "information" (e.g. photo) for, you add to a contact subscription and you will be called back whenever the information you wish to have is available or changed. Microsoft provide a howto使用联系人订阅。

所以没有办法得到图像"now"。显示照片可能需要一段时间。因此,最好显示您拥有的内容并在收到回调时更新。