2

有没有办法只搜索 GAL 中联系人的 givenName 或 LastName 或电子邮件地址?目前我有这些代码:

Private Sub QuickSearch() 'Working!
    Dim oApp As New Outlook.Application
    Dim eu As Outlook.ExchangeUser = oApp.GetNamespace("MAPI").AddressLists("Global Address List").AddressEntries("Justin Timberlake").GetExchangeUser()
    If Not eu Is Nothing Then
        response.write(eu.Name + ": " + eu.Alias + ", " + eu.FirstName + ", " + eu.LastName + ", " + eu.MobileTelephoneNumber + ", " + eu.Department + ", " + eu.PrimarySmtpAddress)
    End If
    oApp.Quit()
End Sub

好吧,这个就像通过 AddressList GAL 进行的快速搜索一样。但是出现了一个问题,例如我有这些联系人姓名:

- 贾斯汀比伯

- 贾斯汀汀布莱克

我搜索了贾斯汀,只有贾斯汀比伯会是结果,因为它是第一个出现在列表中的人。

4

1 回答 1

0

您需要在 AddressEntries 处停止,然后遍历列表

    Dim oApp As New Outlook.Application
    Dim aeList As Outlook.AddressEntries = oApp.GetNamespace("MAPI").AddressLists("Global Address List").AddressEntries("Justin Timberlake")
    If Not aeList Is Nothing Then
        For Each ae As Outlook.AddressEntry aeList
            Dim eu As Outlook.ExchangeUser = ae.GetExchangeUser()
            response.write(eu.Name + ": " + eu.Alias + ", " + eu.FirstName + ", " + eu.LastName + ", " + eu.MobileTelephoneNumber + ", " + eu.Department + ", " + eu.PrimarySmtpAddress)
        Next
    End If
于 2013-02-18T03:27:16.207 回答