Solved: Retrieve Outlook Contact Data
I want to be able to click a button which opens an Outlook "Select Names" window (or some other window that allows me to select the contact) , select a contact, then have the following data transferred to my sheet:
Company
First Name
Last Name
Address
City
State
Zip
Work Phone
Work Fax
Email Address
Anybody know how to do this? Thanks.
Found out how to display the dialog box, but now, how to get at the data?
The method below will pop up the Outlook Address dialog box, which is what I want. Now, how to take that and extract the data that I want, that's the question. Any ideas?
Sub SetContactsFolderAsInitialAddressList()
Dim oMsg As Outlook.MailItem
Set oMsg = Outlook.Application.CreateItem(olMailItem)
Dim oDialog As Outlook.SelectNamesDialog
Set oDialog = Outlook.Application.Session.GetSelectNamesDialog
Dim oAL As Outlook.AddressList
Dim oContacts As Outlook.Folder
Set oContacts = _
Outlook.Application.Session.GetDefaultFolder(olFolderContacts)
On Error GoTo HandleError
'Look for the AddressList for the default Contacts folder
For Each oAL In Outlook.Application.Session.AddressLists
If oAL.AddressListType = olOutlookAddressList Then
If oAL.GetContactsFolder.EntryID = _
oContacts.EntryID Then
Exit For
End If
End If
Next
With oDialog
.Caption = "Select Customer Contact"
.ToLabel = "Customer C&ontact"
.NumberOfRecipientSelectors = olShowTo
.InitialAddressList = oAL
.AllowMultipleSelection = False
'Let the selected names be the recipients of the new message
.Recipients = oMsg.Recipients
If .Display Then
'Recipients Resolved
End If
End With
HandleError:
Exit Sub
End Sub