2

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

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”,因为该事件已被标记为会议类别。

但是我真正想做的是找到所有这些事件。以下无法匹配任何事件:

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

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

4

1 回答 1

0

请参阅按类别搜索 Outlook 联系人

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

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
于 2013-09-18T21:25:46.547 回答