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

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

问题描述

我试着写在OSX的AppleScript过滤展望基于事件的类别,例如苹果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事件,最后一行显示真作为本次活动已经打上了会议范畴。

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}

是否有不同的语法使用,或者这是展望为Mac的限制,也许不允许以嵌套的集合筛选事件(类别属性在日历事件对象)?

推荐答案

请参见搜索Outlook联系人通过类别

下面我们使用聚光灯/ 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类别进行过滤Mac的Outlook日历事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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