我是脚本新手,正在尝试为邮件编写一个简单的脚本。我将在 ical 活动中使用它来发送草稿文件夹中的所有电子邮件。但是我遇到了一个错误,我不确定如何调试。这是我的脚本
tell application "Mail"
set draftMessages to every message in drafts mailbox
repeat with theMessage in draftMessages
set theSender to (sender of theMessage)
set theSubject to (subject of theMessage)
set theContent to (content of theMessage)
set theRecipients to (to recipients of theMessage)
set theAddress to (address of theRecipients)
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, sender:theSender, address:theAddress, visible:true}
end repeat
end tell
这是事件日志,其中敏感信息替换为废话。
tell application "Mail"
get every message of drafts mailbox
--> {message id 23241 of mailbox "Drafts" of account "BLAH", message id 23236 of mailbox "Drafts" of account "BLAH"}
get sender of message id 23241 of mailbox "Drafts" of account "BLAH"
--> "Blah Blah <blah@blah.com>"
get subject of message id 23241 of mailbox "Drafts" of account "BLAH"
--> "test 2"
get content of message id 23241 of mailbox "Drafts" of account "BLAH"
--> "test 2"
get every to recipient of message id 23241 of mailbox "Drafts" of account "BLAH"
--> {to recipient 1 of message id 23241 of mailbox "Drafts" of account "BLAH"}
Result:
error "Can’t get address of {to recipient 1 of message id 23241 of mailbox \"Drafts\" of
account \"BLAH\" of application \"Mail\"}." number -1728 from «class radd» of {«class
trcp» 1 of «class mssg» id 23241 of «class mbxp» "Drafts" of «class mact» "BLAH"}