Thanasis
Thanasis

Reputation: 725

Extracting Outlook Contact Information with VBA

I am trying to extract email addresses from the contact information section of a contact in Outlook, however, I cannot access the same data that is displayed when right clicking on a contact and navigating to Outlook Properties > E-Mail Addresses.

Contact Information

How might I access this programmatically?

Upvotes: 0

Views: 2925

Answers (2)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66296

What you have above is not a contact, this is a GAL address entry. The data in the screenshot is stored in the PR_EMS_AB_PROXY_ADDRESSES MAPI property (DASL name http://schemas.microsoft.com/mapi/proptag/0x800F101F ).

The script below will display proxy addresses of the EX sender of the currently selected message in Outlook:

Set msg = Application.ActiveExplorer.Selection(1)
Set vSender = msg.Sender
vProxyAddresses = vSender.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101F")
For Index = LBound(vProxyAddresses) To UBound(vProxyAddresses)
  MsgBox vProxyAddresses(Index)
Next

Upvotes: 1

C8H10N4O2
C8H10N4O2

Reputation: 19025

ContactItem.Email1Address

Returns or sets a String representing the e-mail address of the first e-mail entry for the contact. Read/write.

via MSDN

Gregthatcher.com has a report script that can be modified for this task. Basically you Set ContactFolder = Session.GetDefaultFolder(olFolderContacts) and then loop through For Each currentItem In ContactFolder.Items, check for class Class = olContact then get the currentItem.Email1Address.

Upvotes: 2

Related Questions