【问题标题】:Outlook Address Book Search (No Looping?)Outlook 通讯簿搜索(无循环?)
【发布时间】:2017-04-19 16:01:46
【问题描述】:

无论如何,是否可以使用他们的电子邮件地址在 Outlook 地址框中搜索联系人而不使用任何类型的 For 循环?我们的全球联系人列表中有如此多的联系人,而且要花很长时间才能浏览该列表。是否没有可以应用于联系人列表的搜索或查找功能。

如果在联系人列表中找到用户,我正在寻找电话号码和办公室等信息。

我发现的所有解决方案都涉及遍历联系人列表。 http://www.ozgrid.com/forum/showthread.php?t=76588

https://msdn.microsoft.com/en-us/library/office/ff869721.aspx

【问题讨论】:

    标签: excel vba outlook


    【解决方案1】:

    使用Namespace.CreateRecipient/Recipient.Resolve解析通讯录中的姓名(或地址)。即使你传递了一个 SMTP 地址,它也会被解析给一个 GAL 用户(如果有匹配的话)。

    【讨论】:

    • 德米特里,我想我错过了把它放在原始问题中。我有用户的电子邮件,我想在通讯录中找到它。然后获取电话号码和办公室等信息(更新了主帖)。不确定我是否可以提取除 Outlook.recipient 名称之外的信息。
    • 当然可以 - 使用 Recipient.AddressEntry。从那里您可以使用 AddressEntry.GetExchangeUser 或 AddressEntry.PropertyAccessor.GetProperty 读取任何 MAPI 属性(使用 OutlookSpy 查看可用的内容)。
    • 谢谢。这太棒了。这应该可以满足我的需要。完成后将发布代码。
    • 再次感谢德米特里。发布了一个宏来搜索联系电话#作为单独的答案,因为我无法在 cmets 中放置代码。
    【解决方案2】:

    这是我用来使用全球通讯录中的电子邮件地址获取联系人电话号码的解决方案 - 使用 Dmitry Streblechenko 方法。

    Sub GetPhone(EmailAddress As String) 'Gets the phone # for contact
    Dim OutApp As Outlook.Application
    Dim OutMail As Object
    Dim OutRecipients As Outlook.Recipient
    Dim PhoNe As String
    
    
    On Error Resume Next
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
    Set OutRecipients = OutMail.Recipients.Add(EmailAddress)
    OutRecipients.Resolve
    
    PhoNe = OutRecipients.AddressEntry.GetExchangeUser.BusinessTelephoneNumber
    Set OutRecipients = Nothing
    Set OutMail = Nothing
    Set OutApp = Nothing
    On Error GoTo 0
    End Sub
    

    【讨论】:

    • 绝对没有理由创建一个虚拟电子邮件。使用 Namespace.CreateRecipient / Recipient.Resolve。
    • 尝试使用 Namespace.CreateRecipient 但遇到了一个错误,我没有时间接受它。我需要一个真正快速的功能宏。我以前用电子邮件解析收件人,所以这就是我走这条路的原因。如果有机会,我会用 Namespace.CreateRecipient 再试一次。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多