如何在 macOS 的邮件应用中打开我在搜索结果中选择的邮件所在的 folder/mailbox?
How to open the folder/mailbox where is located a message I selected in a search result in the Mail App on macOS?
在 macOS 的邮件应用程序中,我使用许多智能文件夹(显示预定义搜索条件结果的特定邮箱)。因此,这些智能邮箱显示来自不同帐户和文件夹的邮件。
通常,我需要跳转到结果列表中 select 消息所在的实际 mailbox/folder。我也有很多文件夹。
新邮件应用程序的改进(烦恼)之一是我找不到实现该功能的方法。在过去的 macOS 版本中(至少到 Mavericks 为止),这很容易。我可以像在许多其他应用程序中一样做同样的事情。看图。
之前的技巧在邮件应用程序的消息 windows 中不再起作用。
有什么方法可以跳转或打开搜索结果或智能邮箱中select我select的消息吗?
使用 Automator + AppleScript 的解决方案
我找到的解决方案是创建一个 Automator 服务,并可选择将其与快捷方式相关联。
- 打开 Automator。
- 新文档。
- Select
Service
文档类型。
- 在 window 的顶部,设置此服务的输入类型:
Service receives selected
选择no input
in
选择Mail.app
- 在动作库(左窗格)中找到动作
Run AppleScript
。
- 将其拖放到工作流区域。
- 复制此答案末尾的代码并将其粘贴到操作中
Run AppleScript
。
- 保存您的服务(例如 "Jump to Folder")。
测试服务
测试服务时,Automator 可以保持打开状态,邮件应用程序也可以保持打开状态。
- 打开邮件应用程序。
- 进行搜索并select一封邮件,最好是位于自定义文件夹中的邮件。
- 在菜单栏中转到
Mail
> Services
。您应该会看到您的新服务。
- Select 服务。
selected 和活动 mailbox/folder 应该是之前 selected 消息的邮箱。
可选。为您的服务分配快捷方式:
- 打开系统偏好设置。
- 前往
Keyboard
> Shortcuts
- 在左窗格中 select
Services
- 在右窗格的末尾
General
您应该可以找到您的服务
- 为其分配一个快捷方式(例如CMD-OPTION-J)
代码
set theDialogTitle to "Go to Folder Script"
tell application "Mail"
-- Get the selected messages and the count of them
set theMessageList to selected messages of message viewer 1
set theCount to length of theMessageList
-- Error if no messages
if theCount is 0 then
display dialog ¬
"No message selected." with title theDialogTitle buttons {"OK"} with icon caution
return
end if
-- Error if more than one message
if theCount is greater than 1 then
display dialog ¬
"Must select only one message." with title theDialogTitle buttons {"OK"} with icon caution
return
end if
-- Get the message
set theMessage to item 1 of theMessageList
-- Get the mailbox object
set theMailbox to mailbox of theMessage
-- Select the mailbox
set selected mailboxes of message viewer 1 to theMailbox
end tell
在 macOS 的邮件应用程序中,我使用许多智能文件夹(显示预定义搜索条件结果的特定邮箱)。因此,这些智能邮箱显示来自不同帐户和文件夹的邮件。
通常,我需要跳转到结果列表中 select 消息所在的实际 mailbox/folder。我也有很多文件夹。
新邮件应用程序的改进(烦恼)之一是我找不到实现该功能的方法。在过去的 macOS 版本中(至少到 Mavericks 为止),这很容易。我可以像在许多其他应用程序中一样做同样的事情。看图。
之前的技巧在邮件应用程序的消息 windows 中不再起作用。
有什么方法可以跳转或打开搜索结果或智能邮箱中select我select的消息吗?
使用 Automator + AppleScript 的解决方案
我找到的解决方案是创建一个 Automator 服务,并可选择将其与快捷方式相关联。
- 打开 Automator。
- 新文档。
- Select
Service
文档类型。 - 在 window 的顶部,设置此服务的输入类型:
Service receives selected
选择no input
in
选择Mail.app
- 在动作库(左窗格)中找到动作
Run AppleScript
。 - 将其拖放到工作流区域。
- 复制此答案末尾的代码并将其粘贴到操作中
Run AppleScript
。 - 保存您的服务(例如 "Jump to Folder")。
测试服务
测试服务时,Automator 可以保持打开状态,邮件应用程序也可以保持打开状态。
- 打开邮件应用程序。
- 进行搜索并select一封邮件,最好是位于自定义文件夹中的邮件。
- 在菜单栏中转到
Mail
>Services
。您应该会看到您的新服务。 - Select 服务。
selected 和活动 mailbox/folder 应该是之前 selected 消息的邮箱。
可选。为您的服务分配快捷方式:
- 打开系统偏好设置。
- 前往
Keyboard
>Shortcuts
- 在左窗格中 select
Services
- 在右窗格的末尾
General
您应该可以找到您的服务 - 为其分配一个快捷方式(例如CMD-OPTION-J)
代码
set theDialogTitle to "Go to Folder Script"
tell application "Mail"
-- Get the selected messages and the count of them
set theMessageList to selected messages of message viewer 1
set theCount to length of theMessageList
-- Error if no messages
if theCount is 0 then
display dialog ¬
"No message selected." with title theDialogTitle buttons {"OK"} with icon caution
return
end if
-- Error if more than one message
if theCount is greater than 1 then
display dialog ¬
"Must select only one message." with title theDialogTitle buttons {"OK"} with icon caution
return
end if
-- Get the message
set theMessage to item 1 of theMessageList
-- Get the mailbox object
set theMailbox to mailbox of theMessage
-- Select the mailbox
set selected mailboxes of message viewer 1 to theMailbox
end tell