VBA:给定一个电子邮件地址,如何在 GAL 中查找它们?
我正在编写一个 VBA 宏,它将扫描我的收件箱,确定谁经常给我发电子邮件,然后自动将他们(带有多个选择字段)作为新联系人添加到我的个人通讯簿中。
首先,我编写了一些非常简单的 VBA,它可以查看收件箱中的所有电子邮件,并为 Microsoft Exchange 服务器上的用户显示 SenderEmailAddress:
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
我现在有了电子邮件地址,因此下一步是查看它们上GAL。然而,我见过的解决方案涉及扫描整个 GAL,这在一家拥有(字面上)数以万计的条目的公司中似乎并不高效或实用 - 并且可能会让我受到轻微的惩罚。信息技术部门。
因此,鉴于电子邮件地址(看起来类似于 /O=MYCOMPANY/OU=EUROPE/CN=RECIPIENTS/CN=RICHARD),查找此联系人的最佳方式是什么GAL 以便我可以获取“电话”、“助理”、“职务”和“手机”字段?
我正在使用 Outlook 2003。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太了解您可以使用 GAL 做什么,但是,根据您公司中的设置方式,您可以尝试查询 Active Directory 以获取这些字段。您可以对特定用户执行查询,从而避免有效地“下载”地址簿。
有关如何通过 VBA 访问它的大量信息,以及一些帮助您入门的示例,请访问 http:// www.rlmueller.net/ADOSearchTips.htm
I am not really up to speed on what you can do with the GAL, however, depending on how it's set up in your company you could try querying Active Directory instead for those fields. You can execute queries for specific users which would avoid having to effectively "download" the address book.
There's a lot of information on how to access it via VBA, plus some examples to get you started at http://www.rlmueller.net/ADOSearchTips.htm