我正在尝试在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
属性)过滤事件?
答案 0 :(得分:0)
请参阅Search Outlook contacts by category
我们使用聚光灯/ 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