2011-12-01 77 views
2

有没有办法在GAL中只搜索联系人的givenName或LastName或emailaddress?目前我有这些代码:通过全球通讯录搜索

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快速搜索。但一个问题出现的是,比如我有这些联系人姓名:

- 贾斯汀比伯

- 贾斯汀

而且我搜索了贾斯汀,只有贾斯汀比伯会因为它是第一个在名单上看到的结果。

+0

碰撞迭代!有人请吗? –

回答

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