【发布时间】:2011-11-15 10:06:11
【问题描述】:
我需要为 Mail.app 编写一个 Applescript,它将接收我的收件箱中的所有邮件和超过特定天数的已发送邮件,并将它们移动到“我的 Mac 上”的相应文件夹或本地文件夹中。
这是因为我的 IMAP 帐户有 120 天的配额限制,我宁愿自动将我的电子邮件“归档”到本地文件夹,而不是手动进行。
【问题讨论】:
标签: email applescript
我需要为 Mail.app 编写一个 Applescript,它将接收我的收件箱中的所有邮件和超过特定天数的已发送邮件,并将它们移动到“我的 Mac 上”的相应文件夹或本地文件夹中。
这是因为我的 IMAP 帐户有 120 天的配额限制,我宁愿自动将我的电子邮件“归档”到本地文件夹,而不是手动进行。
【问题讨论】:
标签: email applescript
到目前为止,您尝试过什么?你的问题非常广泛。以下内容应该可以帮助您入门:
property secondsIn120Days : 10368000
tell application "Mail"
set theInbox to inbox
set dateToday to current date
set firstMessage to 1
set lastMessage to (get count of messages in theInbox)
repeat with thisMessage from lastMessage to firstMessage by -1
set currentMessage to message thisMessage of theInbox
set messageDate to date received of currentMessage
set timeDifference to dateToday - messageDate
if timeDifference ≥ secondsIn120Days then
(* In answer to your comment, any folder you create to archive
messages is going to be in the "On My Mac" directory. But say you
create a Smart Mailbox called "Mail Archive" then all you should
need are these lines... *)
set archiveMailbox to (mailbox ("Mail Archive" as string))
move currentMessage to archiveMailbox
end if
end repeat
end tell
更新:在代码中添加了对 cmets 的响应。
【讨论】: