Applescript 邮件存档操作
Applescript Mail archive Actions
因此,我终于厌倦了在我的 Mac 上手动排序和归档电子邮件以绕过一些陈旧的邮箱大小限制。我不喜欢 Apple 处理邮件归档的方式,所以我研究了一些其他人编写的用于对邮件进行分类的示例,并将一个简短的脚本拼凑在一起以过滤我的电子邮件并归档超过 90 天的所有内容。大多数情况下,简单的东西。
有点烦人的是 Mail 没有将 "On My Mac" 视为本地帐户,因此您需要调整代码以盲目引用邮箱名称..但是..它有效。
我想我只是遇到了一个评估问题。我可以很容易地从那里对 "Inbox" 和存档邮件进行排序。
on archive_email(target_account, target_mailbox, destination_account, destination_mailbox, oldemaildate)
tell application "Mail"
#Identify messages that need to be moved. If unread messages shouldn't be moved, change the end of the variable definition to read "is less than oldsentdate and read status is true)
set _msgs_to_capture to (every message of mailbox target_mailbox of account target_account whose date received is less than oldemaildate)
repeat with eachMessage in _msgs_to_capture
set archiveMailbox to (mailbox (destination_mailbox as string))
move eachMessage to archiveMailbox
end repeat
end archive_email
但是,这不适用于 "Sent" 文件夹。我的猜测是 "whose date received is less than" 对 "sent" 文件夹的评估不正确。可悲的是,"whose date sent is..." 似乎也不起作用。我正在努力在这里找到正确的变量和评估。
假设 target_account 和 oldmaildate 具有正确的值,下面的行是完美的。可以肯定的是,我直接把target_mailbox换成了"Sent Messages":
set _msgs_to_capture to every message of mailbox "Sent Messages" of target_account whose date sent is less than oldemaildate
请检查 values/types 个变量。
此外,我建议您在重复循环之前而不是内部设置下面的行,以提高速度:
set archiveMailbox to (mailbox (destination_mailbox as string))
您可以取消效率低下的repeat
循环,并通过一条命令实现移动:
on archive_email(target_account as text, target_mailbox as text, ¬
destination_account as text, destination_mailbox as text, ¬
oldemaildate as date)
tell application "Mail" to ¬
move (every message ¬
of mailbox target_mailbox ¬
of account target_account ¬
whose date sent ¬
is less than oldemaildate) ¬
to mailbox destination_mailbox
end archive_email
对 已发送 项使用 date sent
,我可以确认它有效。
系统信息: AppleScript 版本:“2.7”,系统版本:“10.13.4”
因此,我终于厌倦了在我的 Mac 上手动排序和归档电子邮件以绕过一些陈旧的邮箱大小限制。我不喜欢 Apple 处理邮件归档的方式,所以我研究了一些其他人编写的用于对邮件进行分类的示例,并将一个简短的脚本拼凑在一起以过滤我的电子邮件并归档超过 90 天的所有内容。大多数情况下,简单的东西。
有点烦人的是 Mail 没有将 "On My Mac" 视为本地帐户,因此您需要调整代码以盲目引用邮箱名称..但是..它有效。
我想我只是遇到了一个评估问题。我可以很容易地从那里对 "Inbox" 和存档邮件进行排序。
on archive_email(target_account, target_mailbox, destination_account, destination_mailbox, oldemaildate)
tell application "Mail"
#Identify messages that need to be moved. If unread messages shouldn't be moved, change the end of the variable definition to read "is less than oldsentdate and read status is true)
set _msgs_to_capture to (every message of mailbox target_mailbox of account target_account whose date received is less than oldemaildate)
repeat with eachMessage in _msgs_to_capture
set archiveMailbox to (mailbox (destination_mailbox as string))
move eachMessage to archiveMailbox
end repeat
end archive_email
但是,这不适用于 "Sent" 文件夹。我的猜测是 "whose date received is less than" 对 "sent" 文件夹的评估不正确。可悲的是,"whose date sent is..." 似乎也不起作用。我正在努力在这里找到正确的变量和评估。
假设 target_account 和 oldmaildate 具有正确的值,下面的行是完美的。可以肯定的是,我直接把target_mailbox换成了"Sent Messages":
set _msgs_to_capture to every message of mailbox "Sent Messages" of target_account whose date sent is less than oldemaildate
请检查 values/types 个变量。
此外,我建议您在重复循环之前而不是内部设置下面的行,以提高速度:
set archiveMailbox to (mailbox (destination_mailbox as string))
您可以取消效率低下的repeat
循环,并通过一条命令实现移动:
on archive_email(target_account as text, target_mailbox as text, ¬
destination_account as text, destination_mailbox as text, ¬
oldemaildate as date)
tell application "Mail" to ¬
move (every message ¬
of mailbox target_mailbox ¬
of account target_account ¬
whose date sent ¬
is less than oldemaildate) ¬
to mailbox destination_mailbox
end archive_email
对 已发送 项使用 date sent
,我可以确认它有效。
系统信息: AppleScript 版本:“2.7”,系统版本:“10.13.4”