Binocular222
New Member
- Outlook version
- Email Account
- Exchange Server
The below code display info on selected contact (contact is store in Exchange server and GAL). However, I cannot figure out how to get phone extension, please anyone could help?
Code:
Public Sub testing()
On Error Resume Next
Set DummyEmail = CreateObject("Outlook.Application").CreateItem(olMailItem) 'Create a dummy e-mail to add aliases to
Set Selection = Application.ActiveExplorer.Selection
For Each ContactItem In Selection
With ContactItem
If .Email1AddressType = "EX" Then
Set ActivePersonRecipient = DummyEmail.Recipients.Add(.Account & "@kpmg.com.vn") 'Use the .Account alias to create a recipient object and add it to the dummy e-mail
If ActivePersonRecipient.Resolve Then 'If valid, use the AddressEntry property of the recipient to return an AddressEntry object
Set oExUser = ActivePersonRecipient.AddressEntry.GetExchangeUser 'Use the GetExchangeUser method of the AddressEntry object to retrieve the ExchangeUser object for the recipient.
If Trim(oExUser.Address) <> "" Then 'To counter weird error when sometime ActivePersonRecipient.Resolve to True even if the Exchange account doesn't exist.
resultstr = oExUser.FirstName
MsgBox (resultstr)
End If
End If
End If
End With
Err.Clear
Next
Set AllContactItems = Nothing
End Sub