按类别搜索 Outlook 联系人 [英] Search Outlook contacts by category

查看:30
本文介绍了按类别搜索 Outlook 联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Outlook 2011 for Mac 中按类别搜索联系人?

Is there a way to search for Contacts in Outlook 2011 for the Mac by Categories?

tell application "Microsoft Outlook"

  -- get the category by name
  set theCategory to item 1 of (every category whose name = "Recruiter")

  -- correctly displays 'Recruiter [25]'
  display dialog (name of theCategory) & " [" & (id of theCategory) & "]"

  -- perform the search (incorrectly, it seems)
  set theContacts to (every contact whose (every category contains theCategory))

  -- should display ~100; actually displays 0
  display dialog (count of theContacts)

end tell

推荐答案

我认为 OL 词典实现中可能存在一些关于类别的错误/功能 - 我认为您的搜索语句应该有效,但我同意它.

I think there may be some bugs/features in the OL dictionary implementation with regard to categories - I think your search statement should work, but I agree it doesn't.

对此的一种解决方法是进行聚光灯搜索.这甚至可能更可取,因为它可能比使用 OL 字典更快.简而言之,将您的 set theContacts to ... 行替换为以下内容:

One workaround to this is to do a spotlight search instead. This may even be preferable, because it is probably faster than using the OL dictionary. In short, replace your set theContacts to ... line with the following:

    set currentIdentityFolder to quoted form of POSIX path of (current identity folder as string)
    set theContactIDs to words of (do shell script "mdfind -onlyin " & currentIdentityFolder & "  'kMDItemContentType == com.microsoft.outlook14.contact && com_microsoft_outlook_categories == " & id of theCategory & "' | xargs -I % mdls -name com_microsoft_outlook_recordID '%' | cut -d'=' -f2 | sort -u | paste -s -")

    set theContacts to {}
    repeat with thisContactID in theContactIDs
        set end of theContacts to contact id thisContactID
    end repeat

    -- For example display the first name of the first contact
    display dialog first name of (item 1 of theContacts) as string

这将对您需要的联系人进行聚光灯搜索(mdfind 命令):

This will do a spotlight search (mdfind command) for the contacts you require:

  • 它只会在您当前的身份文件夹中查找
  • 它只会寻找联系人
  • 它只会返回标有招聘人员"类别 ID 的联系人

mdfind 命令的输出是与此查询匹配的文件列表.所以这个输出通过管道传送到 mdls,它会列出所有聚光灯可搜索的字段,包括类别.应将一个简单的联系人 ID 列表返回给 applescript.

The output of the mdfind command is a list of files which match this query. So this output is piped to mdls, which will list all spotlight-searchable fields, including category. A simple list of contact IDs should be returned to applescript.

然后可以使用简单的重复循环将联系人 ID 列表转换为联系人列表.

The list of contact IDs can then be converted to a list of contacts with the simple repeat loop.

这篇关于按类别搜索 Outlook 联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆