简体   繁体   English

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

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

I am working on a little script to help me organize my open messages, and I want to get every open outgoing message in Mail.app. 我正在研究一个小的脚本来帮助我组织打开的邮件,我想在Mail.app中获取所有打开的传出邮件。

When I run the following I get {} back regardless of what outgoing messages I have open. 当我运行以下命令时,无论打开了哪些传出消息,我都会得到{}

tell application "Mail"
    get every outgoing message
end tell

When I however run 但是当我跑步时

tell application "Mail"
    make new outgoing message

    get every outgoing message
end tell

The first instance I get {outgoing message id 44 of application "Mail"} , the second time I get {outgoing message id 44 of application "Mail", outgoing message id 45 of application "Mail"} , etc, as it keeps opening new blank outgoing messages. 我第一次获得{outgoing message id 44 of application "Mail"} ,第二次获得{outgoing message id 44 of application "Mail", outgoing message id 45 of application "Mail"} ,依此类推,因为它一直在打开新的空白传出消息。

So what I'm seeing is that it can only find messages created by Applescript? 所以我看到的是它只能找到Applescript创建消息? Is this a bug or a feature? 这是错误还是功能? Is there a workaround? 有解决方法吗?

The answer was on this other question here: How to set the sender of the current Mail.app outgoing message via AppleScript? 答案是关于另一个问题: 如何通过AppleScript设置当前Mail.app传出消息的发件人?

Sadly and apparently, yes, Applescript is simply broken and they haven't bothered to fix it. 可悲的是,显然,是的,Applescript只是被破坏了,他们没有费心去修复它。

Just to reply to "how to set the sender of the current Mail.app", you're right, the 'sender' property does not work, but you can solved it be selecting first the proper INBOX, linked to the account you want to send from, before creation of new outgoing message :see script bellow which does not involved the GUI scripting (more safe !) 只是回答“如何设置当前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

The words "account 2" in line 4 is the sender account (1, 2,...) and could be replaced by the name of that account like : account "my account". 第4行中的“帐户2”是发送方帐户(1、2,...),可以替换为该帐户的名称,例如:帐户“我的帐户”。 I hope it helps you. 希望对您有帮助。

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

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