Applescript Mail.app "get every outgoing message" 仅显示由脚本创建的消息

Applescript Mail.app "get every outgoing message" only showing messages created by script

我正在编写一个小脚本来帮助我组织打开的消息,我想在 Mail.app.[=17= 中获取 每个 打开的外发消息]

当我 运行 以下内容时,无论我打开了哪些外发消息,我都会 {} 返回。

tell application "Mail"
    get every outgoing message
end tell

然而当我运行

tell application "Mail"
    make new outgoing message

    get every outgoing message
end tell

第一次收到 {outgoing message id 44 of application "Mail"},第二次收到 {outgoing message id 44 of application "Mail", outgoing message id 45 of application "Mail"},等等,因为它不断打开新的空白外发消息。

所以我看到的是它只能找到 Applescript 创建的消息?这是错误还是功能?有解决方法吗?

另一个问题的答案在这里:How to set the sender of the current Mail.app outgoing message via AppleScript?

可悲的是,显然,是的,Applescript 只是坏了,他们没有费心去修复它。

只是回复"how to set the sender of the current Mail.app",你是对的,'sender' 属性 不起作用,但是你可以解决它首先选择正确的收件箱,链接到在创建新的传出消息之前,您要发送的帐户:请参阅下面的不涉及 GUI 脚本的脚本(更安全!)

tell application "Mail"
activate
if not (message viewer 1 exists) then make new message viewer
set selected mailboxes of message viewer 1 to {mailbox "INBOX" of account 2 of application "Mail"}
set newMessage to make new outgoing message with properties {visible:true, subject:"subjet xxx", content:"content free text"}
tell newMessage
    make new to recipient at end of to recipients with properties {name:"", address:"test@gmail.com"}
end tell
end tell

第 4 行中的单词 "account 2" 是发件人帐户 (1, 2,...),可以替换为该帐户的名称,例如:帐户 "my account"。希望对你有帮助。