Skip to content

Instantly share code, notes, and snippets.

@Clijsters
Last active August 29, 2015 14:24
Show Gist options
  • Save Clijsters/458dbb82ece7902b6c25 to your computer and use it in GitHub Desktop.
Save Clijsters/458dbb82ece7902b6c25 to your computer and use it in GitHub Desktop.
A simple VB solution to search for Users in Exchange via Outlook
Function ResolveRecipient(strSearch As String) As Outlook.Recipient
If String.IsNullOrEmpty(strSearch) Then
Throw New Exception _
("Empty string was given to ResolveRecipient Function.", _
New NullReferenceException("strSearch at ResolveRecipient IsNullOrEmpty"))
End If
Dim App As Outlook.Application = New Outlook.Application
Dim NS As Outlook.NameSpace = App.Session
Dim rec As Outlook.Recipient = NS.CreateRecipient(strSearch)
If rec.Resolve Then
Return rec
Else
Throw New Exception("Unable to resolve Recipient")
End If
End Function
@Clijsters
Copy link
Author

At this point you could gather information on this way:

Dim strAlias As String = rec.AddressEntry.GetExchangeUser.Alias
Dim strBusPhone As String = rec.AddressEntry.GetExchangeUser.BusinessTelephoneNumber
'[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment