首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用AppleScript按类别筛选Outlook for Mac日历事件

如何使用AppleScript按类别筛选Outlook for Mac日历事件
EN

Stack Overflow用户
提问于 2013-06-30 14:29:40
回答 1查看 1.6K关注 0票数 2

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

代码语言:javascript
复制
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“,因为此事件已标记为”Conference“类别。

然而,我真正想做的是找到所有这样的事件。以下内容无法匹配任何事件:

代码语言:javascript
复制
set theConferenceList to every calendar event whose categories contains {theCategoryConference}

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

EN

回答 1

Stack Overflow用户

发布于 2013-09-19 05:25:47

请参阅Search Outlook contacts by category

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

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17387825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档