Mail.app AppleScript:将所有邮件复制(复制)到另一个帐户 [英] Mail.app AppleScript: Duplicating (copying) all messages to another account
问题描述
我正在尝试为 Yosemite Mail.app 创建一个 AppleScript,用于制作邮件的副本(而不是存档).
I'm trying to create an AppleScript for Yosemite Mail.app that makes copies (not archives) of messages.
假设我有 3 个帐户:
Let's say I have 3 accounts:
- 主 (IMAP)
- 目标 1 (IMAP)
- 目标 2(交易所)
我想选择主收件箱中的所有邮件——并将这些邮件复制(又名重复)到另外两个帐户的收件箱,即目标 1 和目标 2.最后,将有三个收件箱,全部带有同一组消息 - 再次复制(不是存档).
I want to select all the messages in the Master inbox -- and copy (aka duplicate) those messages to the inboxes of two other accounts, Target 1 and Target 2. In the end, there will be three inboxes, all with the same set of messages -- again copies (not archives).
我尝试过以下方法:
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
但我收到邮件出错:无法设置邮箱"
but I get "Mail got an error: Can’t set mailbox"
想法?
推荐答案
尼尔,这样的事情会奏效.眨眼
Something like this will work, Neil. wink wink
它将从主帐户/邮箱复制邮件,并复制到目标列表中的每个帐户/邮箱对中.
It will copy messages from the master account/mailbox, and into each account/mailbox pair in the target lists.
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
这篇关于Mail.app AppleScript:将所有邮件复制(复制)到另一个帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!