Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Applescript 如何创建要一起移动而不是单独移动的邮件列表?_Applescript - Fatal编程技术网

Applescript 如何创建要一起移动而不是单独移动的邮件列表?

Applescript 如何创建要一起移动而不是单独移动的邮件列表?,applescript,Applescript,我已经设法使这个AppleScript工作了。它基本上是在我的收件箱中搜索我的所有帐户,然后从特定地址中选择任何超过14天的邮件。然后,它继续将这些过滤邮件中的每一条移动到指定的邮箱 set ExcludeList to {"Trash", "Sent", "Drafts", "Deleted Messages", "Archive", "Junk", "Notes"} -- mailboxes you don't want to search set SenderList to {"event

我已经设法使这个AppleScript工作了。它基本上是在我的收件箱中搜索我的所有帐户,然后从特定地址中选择任何超过14天的邮件。然后,它继续将这些过滤邮件中的每一条移动到指定的邮箱

set ExcludeList to {"Trash", "Sent", "Drafts", "Deleted Messages", "Archive", "Junk", "Notes"} -- mailboxes you don't want to search
set SenderList to {"events@goldstar.com", "hello@touchofmodern.com", "staples@e.staples.com", "deals@livingsocial.com"} -- email addresses of senders you want to remove old emails for
set DestinationFolderName to "Old_Newsletters" -- mailbox to move messages to. If you want to just delete them, leave it blank.
set StaleTime to 14 -- days old the message must be before moved or deleted
set ShowMailboxesProgress to true -- determines if you want the "Processing" box displayed for each mailbox
set current_date to current date
set _msgs_to_move to {}

tell application "Mail"
    set everyAccount to every account where enabled is true

    -- Get acount-specific mailboxes
    repeat with eachAccount in everyAccount
        set accountName to the name of eachAccount
        set currentMailbox to mailbox "INBOX" of eachAccount
        set mailboxName to the name of currentMailbox
        if mailboxName is not in ExcludeList then
            if ShowMailboxesProgress then
                display dialog "Processing folder " & mailboxName & " in account " & accountName
            end if
            try
                repeat with SenderToRemove in SenderList
                    set messages_list to (every message of currentMailbox whose sender ends with "<" & SenderToRemove & ">")
                    repeat with i from 1 to number of items in messages_list
                        set theMessage to item i of messages_list
                        set difference to ((current_date) - (date sent of theMessage)) div days
                        if difference is greater than StaleTime then
                            if DestinationFolderName is not equal to "" then
                                move theMessage to mailbox DestinationFolderName of account "BlueStar Studios"
                            else
                                delete theMessage
                            end if
                        end if
                    end repeat
                end repeat
            end try
        end if
    end repeat
    display dialog "Finished!"
end tell
将ExcludeList设置为{“垃圾”、“已发送”、“草稿”、“已删除邮件”、“存档”、“垃圾”、“备注”}——您不想搜索的邮箱
将SenderList设置为{”events@goldstar.com", "hello@touchofmodern.com", "staples@e.staples.com", "deals@livingsocial.com“}--要删除旧电子邮件的发件人的电子邮件地址
将DestinationFolderName设置为“旧时事通讯”--要将邮件移动到的邮箱。如果只想删除它们,请将其留空。
将StaleTime设置为14天--在移动或删除邮件之前,必须先保存邮件
将ShowMailboxesProgress设置为true--确定是否希望为每个邮箱显示“处理”框
将当前_日期设置为当前日期
将_msgs_设置为_移动到{}
告诉应用程序“邮件”
将everyAccount设置为启用为true的每个帐户
--获取特定于帐户的邮箱
对everyAccount中的每个帐户重复此操作
将accountName设置为每个帐户的名称
将currentMailbox设置为每个帐户的邮箱“收件箱”
将mailboxName设置为currentMailbox的名称
如果mailboxName不在ExcludeList中,则
如果显示邮箱,则继续
显示对话框“处理文件夹”&mailboxName&“帐户中”&accountName
如果结束
尝试
使用SenderToRemove在SenderList中重复此操作
将邮件列表设置为(发件人以“”结尾的currentMailbox的每封邮件)
重复以上步骤,i从1到消息列表中的项目数
将消息设置为消息列表的项目i
将差异设置为((当前_日期)-(消息发送日期))div days
如果差异大于时间,则
如果DestinationFolderName不等于“”,则
将邮件移动到邮箱目的地文件夹帐户“蓝星工作室”的名称
其他的
删除消息
如果结束
如果结束
结束重复
结束重复
结束尝试
如果结束
结束重复
显示对话框“完成!”
结束语
看起来效果不错。但是,它需要很长时间才能运行。因为它会单独移动每个过滤的消息。有没有一种方法可以在重复中列出要移动的邮件列表,然后一次性将整个邮件列表移动到另一个文件夹


另外,如果10.7.5有什么不同的话,我正在运行它。

尝试使用如下过滤器参考表单:

set d to (current date) - 14 * days
tell application "Mail"
    repeat with a in (get accounts where enabled is true)
        move (messages of mailbox "INBOX" of account a where date sent < d and (sender ends with "<events@goldstar.com>" or sender ends with "<hello@touchofmodern.com>")) to mailbox "Old_Newsletters" of account "BlueStar Studios"
    end repeat
end tell
将d设置为(当前日期)-14*天
告诉应用程序“邮件”
在中重复(获取启用为true的帐户)
将(发送日期
这真是太棒了!完全缩减了代码并加快了流程!谢谢我唯一要注意的是,在这个设置中,move命令应该是:
move(发送日期的邮箱“收件箱”的消息…
有“帐户a”会产生错误。