【问题标题】:How to filter Outlook for Mac calendar events by category using AppleScript如何使用 AppleScript 按类别筛选 Outlook for Mac 日历事件
【发布时间】:2013-06-27 14:11:55
【问题描述】:

我正在尝试在 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 的限制,它可能不允许基于嵌套集合(calendar event 对象上的categories 属性)过滤事件?

【问题讨论】:

    标签: macos calendar outlook applescript


    【解决方案1】:

    Search Outlook contacts by category

    在这里,我们使用 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多