【问题标题】:Applescript Mail.app "get every outgoing message" only showing messages created by scriptApplescript Mail.app“获取每条传出消息”仅显示脚本创建的消息
【发布时间】:2016-01-20 18:20:06
【问题描述】:

我正在编写一个小脚本来帮助我组织打开的邮件,并且我希望在 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 创建的消息?这是错误还是功能?有解决方法吗?

【问题讨论】:

    标签: macos email scripting applescript


    【解决方案1】:

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

    很遗憾,显然,Applescript 只是坏了,他们没有费心去修复它。

    【讨论】:

      【解决方案2】:

      只是回复“如何设置当前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 行中的“帐户 2”是发件人帐户(1、2、...),可以替换为该帐户的名称,例如:帐户“我的帐户”。希望对你有帮助。

      【讨论】:

      • 虽然没有真正回答我的问题。我希望能够迭代和控制打开的传出消息,显然您只能控制 with applescript 创建的消息。
      猜你喜欢
      • 2017-05-02
      • 2011-11-10
      • 1970-01-01
      • 2017-02-13
      • 2022-07-11
      • 2012-03-20
      • 2011-02-03
      • 2018-06-26
      • 2018-04-29
      相关资源
      最近更新 更多