How to programmatically retrieve address information from Outlook Address Book

I would like to find out how I can retrieve addressing information from the outlook address book.
ie. Street, City, State, etc.

I am using VB.NET but I am know C# as well.


Charlie
Charles SugdenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Charles SugdenAuthor Commented:
I looked at the code and it doesnt seem to retrieve any data. It just seems to play around with the outlook fields. I was using some code to get simple info


            For Each Recipient As Object In colCDORecips
                If Recipient.Type = 1 Then
                    FirstName = Recipient.AddressEntry.Fields(PR_GIVEN_NAME).value
                    LastName = Recipient.AddressEntry.Fields(PR_SURNAME).value
                    Telephone = Recipient.AddressEntry.Fields(PR_BUSINESS_TELEPHONE_NUMBER).value
                    objEmailAddresses = Recipient.AddressEntry.Fields(PR_EMS_AB_PROXY_ADDRESSES)
                end if
          next
0
Charles SugdenAuthor Commented:
I finally worked out the remainder of the answer myself. The code is in the attached snippet for the curious.

Charlie
        Dim objCDOSession As MAPI.Session
        Dim colCDORecips As MAPI.Recipients
        Dim Recipient As MAPI.Recipient
        Dim objEmailAddresses As Object
            objCDOSession = CreateObject("MAPI.Session")
            objCDOSession.Logon(, , False, False)
 
            colCDORecips = objCDOSession.AddressBook(, "Please choose analysts...", False, True, 1, "Analyst")
            If colCDORecips Is Nothing Then
                Return False
            Else
                colCDORecips.Resolve()
            End If
 
For i As Integer = 0 To colCDORecips.Count - 1
 
Recipient = colCDORecips.Item(1)
FirstName=Recipient.AddressEntry.Fields(PR_GIVEN_NAME).value
LastName=Recipient.AddressEntry.Fields(PR_SURNAME).value
Telephone=Recipient.AddressEntry.Fields(PR_BUSINESS_TELEPHONE_NUMBER).value
objEmailAddresses=Recipient.AddressEntry.Fields(PR_EMS_AB_PROXY_ADDRESSES)
PoCode=Recipient.AddressEntry.Fields(PR_BUSINESS_ADDRESS_POSTAL_CODE).value
Address=Recipient.AddressEntry.Fields(PR_BUSINESS_ADDRESS_STREET).value
City=Recipient.AddressEntry.FieldsPR_BUSINESS_ADDRESS_CITY).value
State=Recipient.AddressEntry.FieldsPR_BUSINESS_ADDRESS_STATE_OR_PROVINCE).value
Country=Recipient.AddressEntry.Fields(PR_BUSINESS_ADDRESS_COUNTRY).value
objCDOSession.Logoff()
If Not objCDOSession Is Nothing Then
  Marshal.ReleaseComObject(objCDOSession)
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Charles SugdenAuthor Commented:
I have answered the question myself and posted a solution...
0
Vee_ModCommented:
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.