【问题标题】:Applescript to archive email in Mail.appApplescript 在 Mail.app 中存档电子邮件
【发布时间】:2011-11-15 10:06:11
【问题描述】:

我需要为 Mail.app 编写一个 Applescript,它将接收我的收件箱中的所有邮件和超过特定天数的已发送邮件,并将它们移动到“我的 Mac 上”的相应文件夹或本地文件夹中。

这是因为我的 IMAP 帐户有 120 天的配额限制,我宁愿自动将我的电子邮件“归档”到本地文件夹,而不是手动进行。

【问题讨论】:

    标签: email applescript


    【解决方案1】:

    到目前为止,您尝试过什么?你的问题非常广泛。以下内容应该可以帮助您入门:

    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
    

    更新:在代码中添加了对 cme​​ts 的响应。

    【讨论】:

    • 我见过这个:doughellmann.com/projects/MailArchiveByDate。基本上我想这样做,但没有按月分类。我希望它都在一个顶级文件夹中。
    • 您为归档邮件而创建的任何文件夹都将位于“在我的 Mac 上”目录中。但是假设您创建了一个名为“Mail Archive”的智能邮箱,那么您只需要这些行...“Set archiveMailbox to (mailbox ("Mail Archive" as string)) \r move currentMessage to archiveMailbox”请参阅上面的更新代码格式正确。
    猜你喜欢
    • 1970-01-01
    • 2013-07-29
    • 2021-10-30
    • 1970-01-01
    • 2011-08-09
    • 1970-01-01
    • 2014-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多