简体   繁体   中英

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 .

联系信息

How might I access this programmatically?

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM