【问题标题】:Assign Outlook for Mac categories with Applescript?使用 Applescript 分配 Outlook for Mac 类别?
【发布时间】:2021-01-25 18:36:12
【问题描述】:

寻找问题的解决方案。不太喜欢在 Outlook 界面中如何分配所有鼠标移动和其他东西的类别,那么如何使其与 Applescript 一起使用?

针对那个问题,我创建了这个 Applescript,让您可以为选定的邮件分配多个类别,然后将邮件移动到与邮件发送年份对应的文件夹中。

display dialog ("Enter Category...") ¬
    default answer "" buttons {"Tag & Move", "Tag", "Cancel"} default button "Tag & Move"
copy the result as list to {the myCategories, the myTagButton}

if myTagButton is "Cancel" then
    return
end if

--- Get comma separated string and convert to list
set old_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {", "}
set category_list to text items of myCategories
set AppleScript's text item delimiters to old_delimiters

--- Set category to each item of list
tell application "Microsoft Outlook"

    --- The set category needs a special list to work with multiple tags...
    --- Create a list {category "tag1", category "tag2", ...}
    set my_categorylist to {}
    repeat with categoryitem in category_list
            set end of my_categorylist to category categoryitem
    end repeat

    --- apply the list of categories to all selected messages
    --- set category of (item 1 of (get current messages)) to my_categorylist
    set msgSet to current messages
    if msgSet = {} then
        error "No messages selected. Select at least one message."
        error -128
    end if
    repeat with aMessage in msgSet
        set category of (item 1 of aMessage) to my_categorylist
        --- Move the message if so told by first dialog
        --- I file by year, so get the date the message was sent and move it there
        if myTagButton is "Tag & Move" then
            set theDate to time sent of aMessage
            set theYear to year of theDate as string
            move aMessage to mail folder theYear
        end if
    end repeat
end tell

在对话框中输入的类别为“foo, bar”,不带引号。如果其中一个类别在运行之前不存在,则脚本将崩溃。

【问题讨论】:

  • 您应该将脚本作为问题的答案发布,然后将其标记为已接受的答案。否则问题将永远留在未回答的队列中。

标签: applescript outlook-2011


【解决方案1】:

我知道这是旧的,但脚本有一个小问题。

这一行:

copy the result as list to {the myCategories, the myTagButton}

具有向后的参数,应该是

copy the result as list to {the myTagButton, the myCategories}

更有用的是根据 Outlook 中可用的类别从列表中选择类别。

【讨论】:

  • 我发现我不得不两次更改该行,多年来存在一些不一致之处。我同意拥有所有类别的列表会很好,但微软将其隐藏在云中。最新版本的 Outlook 365 甚至不支持 AppleScript。然而,7 年后有人可能会使用它,这让我很高兴。
猜你喜欢
  • 2013-06-27
  • 1970-01-01
  • 2017-05-04
  • 2020-11-09
  • 1970-01-01
  • 2015-05-22
  • 2014-03-25
  • 2013-05-29
  • 1970-01-01
相关资源
最近更新 更多