2

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.

4

1 回答 1

0

我不太了解您可以使用 GAL 做什么,但是,根据您公司的设置方式,您可以尝试查询 Active Directory 来代替这些字段。您可以对特定用户执行查询,从而避免必须有效地“下载”地址簿。

有很多关于如何通过 VBA 访问它的信息,还有一些示例可以帮助您入门http://www.rlmueller.net/ADOSearchTips.htm

于 2011-02-24T23:30:48.337 回答