如何使用 AppleScript 按类别过滤 Outlook for Mac 日历事件 [英] How to filter Outlook for Mac calendar events by category using AppleScript

查看:19
本文介绍了如何使用 AppleScript 按类别过滤 Outlook for Mac 日历事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 OSX 上编写 Applescript 以根据事件类别过滤 Outlook for Mac 2011 日历事件,例如找到所有标记为会议"的事件.例如,我有一个名为WWDC"的日历事件,可以通过以下脚本找到:

I'm trying to write an Applescript on OSX to filter Outlook for Mac 2011 calendar events based on event categories, e.g. find all events tagged as "Conference". For example, I have a calendar event named "WWDC" that is found by the following script:

tell application "Microsoft Outlook"
  set theCategoryConference to first category whose name is "Conference"
  set theConferenceList to every calendar event whose (subject is "WWDC")
  display dialog "There were " & (count of theConferenceList) & " Conferences."
  set theEvent to item 1 of items of theConferenceList
  display dialog "Categories contains conference: " & (categories of theEvent contains {theCategoryConference})
end tell

上面找到了 1 个事件,最后一行显示true",因为该事件已被标记为会议类别.

The above finds 1 event, and the final line displays "true" as this event has been tagged with the Conference category.

但是我真正想做的是找到所有此类事件.以下无法匹配任何事件:

However what I really want to do is find all such events. The following fails to match any events:

set theConferenceList to every calendar event whose categories contains {theCategoryConference}

是否有不同的语法可供使用,或者这是 Outlook for Mac 的限制,可能不允许基于嵌套集合过滤事件(calendar event 上的 categories 属性 对象)?

Is there a different syntax to use, or is this a limitation of Outlook for Mac that perhaps doesn't allow filtering events based on a nested collection (the categories attribute on calendar event objects)?

推荐答案

参见 搜索 Outlook 联系人类别

这里我们使用spotlight/mdfind/mdls 解决方法来查找所有相关的分类事件.

Here we use the spotlight/mdfind/mdls workaround to find all the relevant categorized events.

tell application "Microsoft Outlook"
    set theCategoryConference to first category whose name is "Conference"
    set theConferenceList to every calendar event whose (subject is "WWDC")
    display dialog "There were " & (count of theConferenceList) & " Conferences."
    set theEvent to item 1 of items of theConferenceList
    display dialog "Categories contains conference: " & (categories of theEvent contains {theCategoryConference})
    --set theConferenceList to every calendar event whose categories contains {theCategoryConference}

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

    set theConferenceList to {}
    repeat with thisEventID in theEventIDs
        set end of theConferenceList to calendar event id thisEventID
    end repeat

    -- For example display the subject of the first event
    display dialog subject of (item 1 of theConferenceList) as string
end tell

这篇关于如何使用 AppleScript 按类别过滤 Outlook for Mac 日历事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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