【问题标题】:Mail.app AppleScript: Duplicating (copying) all messages to another accountMail.app AppleScript:将所有邮件复制(复制)到另一个帐户
【发布时间】:2015-02-16 23:46:49
【问题描述】:

我正在尝试为 Yosemite Mail.app 创建一个 AppleScript,用于制作邮件的副本(而非存档)。

假设我有 3 个帐户:

  • 主 (IMAP)
  • 目标 1 (IMAP)
  • 目标 2(交换)

我想选择主收件箱中的所有邮件 - 并将这些邮件复制(也称为复制)到另外两个帐户的收件箱,目标 1 和目标 2。最后,将有三个收件箱,所有同一组消息——再次复制(不是存档)。

我尝试过类似的方法:

set mailboxMaster to "Master"
set mailboxTargets to {"Target 1", "Target 2"}

repeat with curMailboxTarget in mailboxTargets
tell application "Mail"
    duplicate every message in mailbox "Master" to mailbox curMailboxTarget
end tell
end repeat

但我收到“邮件出错:无法设置邮箱”

想法?

【问题讨论】:

    标签: applescript osx-yosemite


    【解决方案1】:

    这样的事情会奏效,尼尔。 眨眼眨眼

    它将消息从主帐户/邮箱复制到目标列表中的每个帐户/邮箱对中。

    property masterAccount : "MySourceAccountName"
    property mailboxMaster : "INBOX"
    
    property targetAccounts : {"IMAPAccountName", "ExchangeName"}
    property mailboxTargets : {"INBOX", "Inbox"}
    
    -- set the source mailbox and account
    tell application "Mail"
        set sourceBox to mailbox mailboxMaster of account masterAccount
        set theCount to count of messages of sourceBox
        set theCount to 3 -- to run a test with a limited number
    
    end tell
    if theCount < 0 then error "No messages in the source mailbox."
    
    -- set progress indicator
    set progress total steps to theCount
    
    -- iterate for each account name in targetAccounts
    repeat with a from 1 to (count targetAccounts)
        set acctName to item a of targetAccounts
        set boxName to item a of mailboxTargets
    
        -- set destination mailbox for this target account
        tell application "Mail" to set destinationBox to mailbox boxName of account acctName
    
        -- process each message
        repeat with n from 1 to theCount
            -- iterate the progress indicator
            set progress description to "Copying Message " & n & " of " & theCount
    
            -- duplicate the message
            tell application "Mail" to duplicate (message n of sourceBox) to destinationBox
    
            -- terminate the progress indicator
            set progress completed steps to n
        end repeat
    end repeat
    

    【讨论】:

      猜你喜欢
      • 2022-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-17
      相关资源
      最近更新 更多