Mail.app AppleScript:将所有邮件复制(复制)到另一个帐户

Mail.app AppleScript:将所有邮件复制(复制)到另一个帐户,applescript,osx-yosemite,Applescript,Osx Yosemite,我正在尝试为Yosemite Mail.app创建一个AppleScript,用于复制而不是归档邮件 假设我有3个账户: 主IMAP 目标1 IMAP 目标2交换 我想选择主收件箱中的所有邮件,并将这些邮件复制到其他两个帐户(目标1和目标2)的收件箱中。最后,将有三个收件箱,所有收件箱都有相同的消息集——同样是副本而不是存档 我试过这样的方法: set mailboxMaster to "Master" set mailboxTargets to {"Target 1", "Target 2"}

我正在尝试为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
但我收到邮件时出错:无法设置邮箱


想法?

尼尔,像这样的想法会奏效的。眨眼

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

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