Outlook通讯簿搜索(没有循环?)

时间:2017-04-19 16:01:46

标签: excel-vba outlook outlook-vba vba excel

无论如何使用他们的电子邮件地址搜索联系人的Outlook地址框而没有任何For Loops?我们的全球联系人列表中有如此多的联系人,并且需要永远查看清单。是否没有可以应用于联系人列表的搜索或查找功能。

我希望在联系人列表中找到用户的电话号码和办公室等信息。

我发现的所有解决方案都涉及循环访问联系人列表。 http://www.ozgrid.com/forum/showthread.php?t=76588

https://msdn.microsoft.com/en-us/library/office/ff869721.aspx

2 个答案:

答案 0 :(得分:0)

使用Namespace.CreateRecipient / Recipient.Resolve解析地址簿中的名称(或地址)。即使您传递了SMTP地址,也会将其解析为GAL用户(如果匹配)。

答案 1 :(得分:0)

这是我使用Dmitry Streblechenko方法使用全球通讯录中的电子邮件地址获取联系人电话号码的解决方案。

Sub GetPhone(EmailAddress As String) 'Gets the phone # for contact
Dim OutApp As Outlook.Application
Dim OutMail As Object
Dim OutRecipients As Outlook.Recipient
Dim PhoNe As String


On Error Resume Next
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

Set OutRecipients = OutMail.Recipients.Add(EmailAddress)
OutRecipients.Resolve

PhoNe = OutRecipients.AddressEntry.GetExchangeUser.BusinessTelephoneNumber
Set OutRecipients = Nothing
Set OutMail = Nothing
Set OutApp = Nothing
On Error GoTo 0
End Sub
相关问题