适用于Outlook 2011的Applescript,用于将所有邮件从与源帐户匹配的特定文件夹移动到其他文件夹

时间:2014-04-06 14:45:39

标签: outlook applescript account

正如标题所述“帮助Outlook 2011的Applescript将所有邮件从与源帐户匹配的特定文件夹移动到其他文件夹。”

所以,我有一个“规则”,将我的交换帐户上的所有新邮件移动到“我的电脑”子文件夹中的“收件箱”中。当我从此子文件夹收件箱中删除项目时,它将进入“我的电脑”中的“已删除邮件”。我在“收件箱”子文件夹的相同位置创建了“已删除邮件”的子文件夹,我想按计划运行一个Applescript,可以进入我的计算机上的主要已删除邮件并查找邮件从该交换帐户转移到“子文件夹/已删除邮件”。

谷歌搜索我拼凑下面的一起将把所有邮件移到已删除的项目中:

tell application "Microsoft Outlook"
set topFolder to mail folder "AT&T" of on my computer
set destFolder to folder "Deleted Items" of topFolder
move every message of mail folder "Deleted Items" of on my computer to destFolder
end tell

我无法通过的部分现在只选择性地移动“帐户”是特定值的邮件,如下:

tell application "Microsoft Outlook"
set topFolder to mail folder "AT&T" of on my computer
set destFolder to folder "Deleted Items" of topFolder
move (every message of mail folder "Deleted Items" of on my computer whose account = "Att") to destFolder
end tell

尝试按帐户过滤的最后一次添加会导致错误

Microsoft Outlook got an error: Can’t make account into type specifier.

任何帮助表示赞赏!!

1 个答案:

答案 0 :(得分:3)

设计了一个有效的解决方案。选择文件夹中的所有邮件并循环浏览它们,而不是单行,将帐户名称作为文本抓取并进行比较和移动。

tell application "Microsoft Outlook"
    set topFolder to mail folder "AT&T" of on my computer
    set destFolder to folder "Deleted Items" of topFolder
    set srcFolder to mail folder "Deleted Items" of on my computer
    set selectedMessages to messages of srcFolder
    repeat with theMessages in selectedMessages
        set thisAccount to account of theMessages
        if (name of thisAccount as text is "Att") then
            if (is read of theMessages is false) then
                set theMessages's is read to true
            end if
            move theMessages to destFolder
        end if
    end repeat
end tell