这是我用来从全球地址簿中使用电子邮件地址获取联系人电话号码的解决方案 - 使用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
德米特里,我想我错过了把它放在原来的问题。我有用户的电子邮件,我想在地址簿中找到它。然后获取信息,如电话号码和办公室(更新主要职位)。不知道我是否可以提取outlook.recipient名称以外的信息。 –
当然你可以 - 使用Recipient.AddressEntry。从那里您可以使用AddressEntry.GetExchangeUser或AddressEntry.PropertyAccessor.GetProperty来读取任何MAPI属性(使用OutlookSpy查看可用内容)。 –
谢谢。这太棒了。这应该适用于我所需要的。一旦我完成它,将会发布代码。 –