我已經編寫了 - 當然有各種來源的幫助 - 這個腳本來批量重定向郵件:它重定向郵件應用程序中選定的所有郵件。似乎沒有什麼特別的事情發生。如何對使用重定向創建的郵件執行操作?
tell application "Mail"
set AppleScript's text item delimiters to ""
set theRedirectRecipient to "[email protected]"
set theRedirectSender to "Sender"
set theMessages to the selection
repeat with thisMessage in theMessages
tell application "Mail"
set theRedirectedEmail to redirect thisMessage with opening window
tell theRedirectedEmail
if subject of thisMessage is "" then
set subject of theRedirectedEmail to "Mails zonder subject"
end if
make new to recipient at beginning of to recipients with properties {address:theRedirectRecipient}
#delete bcc recipients
#delete cc recipients
end tell
#delay 2
#send theRedirectedEmail
end tell
end repeat
end tell
如上所述,腳本運行正常:它創建重定向郵件,如果我按下發送按鈕,它就像我需要的那樣工作。
但有3行註釋不起作用。刪除行和發送行。我真的不確定我是否在意刪除的內容,但是我已經將它們包括在內以防某些人看到某種模式。
在取消這些行的人給我這個錯誤:
error "Mail got an error: Can’t get every cc recipient of outgoing message id 18." number -1728 from every cc recipient of outgoing message id 18
而且,這並創建一個消息窗口,如果用手工完成的,我可以成功發送。
在取消「發送」行引入了以下錯誤:
error "Mail got an error: outgoing message id 19 doesn’t understand the 「send」 message." number -1708 from outgoing message id 19
因此,我得出的結論是,所創建的消息不表現爲一條消息「應該」。我看到this thread關於似乎顯示此行爲的「傳出消息」。
這條消息是怎麼回事theRedirectEmail
?如何將消息發送到此對象,如delete
和send
?
好吧,我想我明白了,但我沒有得到它與重複工作我'使用;你基本上使用了2步法,有2個'tell'塊,但是由於我在那個循環中,我不確定知道該怎麼做的applescript。有關如何將您的示例與我的代碼合併的任何提示? – Nanne
對不起,我很懶。我用合併版本更新了它。它應該做的伎倆。 –
謝謝!我並不熟悉applescript,因爲你可能已經收集到了,這對我有幫助:D – Nanne