I'm writing a VBA macro which will scan my inbox, determine who emails me a lot and then automatically add them (with a number of select fields) as a new contact into my Personal Address Book.
To start, I've written some pretty simple VBA which looks through all the emails in the inbox and displays the SenderEmailAddress for those who are on the Microsoft Exchange server:
Dim objEmail As Outlook.MailItem
Set objNS = GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
For Each objEmail In objInbox.Items
If objEmail.SenderEmailType = "EX" Then
Debug.Print objEmail.SenderEmailAddress
End If
Next
I now have the email address, so the next step would be to look them up on the GAL. However the solutions I've seen involve scanning the entire GAL, which in a company where there are (literally) tens of thousands of entries doesn't seem to be efficient or practical - and likely to get me a slap on the wrist by the IT department.
So, given that an email address (which will look something similar to /O=MYCOMPANY/OU=EUROPE/CN=RECIPIENTS/CN=RICHARD), what is the best way to look up this contact on the GAL so that I can get hold of the "phone", "assistant", "title" and "mobile" fields?
I'm using Outlook 2003.