繁体   English   中英

Applescript Mail.app“获取所有外发消息”仅显示脚本创建的消息

[英]Applescript Mail.app “get every outgoing message” only showing messages created by script

我正在研究一个小的脚本来帮助我组织打开的邮件,我想在Mail.app中获取所有打开的传出邮件。

当我运行以下命令时,无论打开了哪些传出消息,我都会得到{}

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创建消息? 这是错误还是功能? 有解决方法吗?

答案是关于另一个问题: 如何通过AppleScript设置当前Mail.app传出消息的发件人?

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

只是回答“如何设置当前Mail.app的发件人”,您是对的,“发件人”属性不起作用,但是您可以通过首先选择适当的INBOX(链接到所需帐户)来解决此问题在创建新的传出消息之前从中发送:请参阅下面的脚本,该脚本不涉及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行中的“帐户2”是发送方帐户(1、2,...),可以替换为该帐户的名称,例如:帐户“我的帐户”。 希望对您有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM