這是我用來從全球地址簿中使用電子郵件地址獲取聯繫人電話號碼的解決方案 - 使用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查看可用內容)。 –
謝謝。這太棒了。這應該適用於我所需要的。一旦我完成它,將會發布代碼。 –