AppleScript:获取突出显示Apple Mail消息

问题描述:

我需要能够从当前消息线程获取当前突出显示的消息。AppleScript:获取突出显示Apple Mail消息

  • 线程1
    • 消息1
    • 消息2
    • 消息3 < - 高亮显示的消息
    • 消息4

我曾尝试:

tell application "Mail" 
    set messages to selected messages of first message viewer 
    set msg to first item of messages 
end tell 

但这只是返回当前所选消息的线程。它也不包括线程中的任何传出消息。

您不会说您使用的是什么版本的Mail或Mac OS X,但该脚本不能在Mail 10.2/OS 10.12.2上运行。错误是“邮件出现错误:无法将所有邮件设置为邮件查看器1的选定邮件”。

这一细小的改动对我的作品:

tell application "Mail" 
    set theMessages to selected messages of first message viewer 
    set theMessage to first item of theMessages 
end tell 

如果我跑这对邮件结构你描述然后设置theMessage被选择哪一个。如果选择了倍数,那么在我的测试中,顺序是预期的(从上到下),除非也选择了“线程1”。在这种情况下,订单可能有所不同。

+0

如何获得线程中第n个突出显示的消息?谢谢 – iphaaw

+0

你可以使用像“消息的第n项”。 –