在 Mail.app 中将电子邮件移动到另一个文件夹的快捷方式

在 Mail.app 中将电子邮件移动到另一个文件夹的快捷方式

如何在 OSX Lion 中为 Mail.app 设置键盘快捷键,以便当我使用此快捷键时,收件箱中未读的电子邮件会自动移动到其他先前定义的文件夹?

答案1

打开自动机并创建一个新的服务。将其设置为接收“无输入”,然后拖动运行 AppleScript从左侧窗格到右侧窗格。

粘贴以下脚本 — 请注意,您必须更改my-account为源邮箱和目标邮箱所在帐户的实际名称*。此外,还要更改destination为指定帐户下的目标邮箱的名称。

tell application "Mail"
    repeat with theMessage in {messages in mailbox "INBOX" of account "my-account" where read status is false}
        set theMailbox to mailbox "destination" of account "my-account"
        move theMessage to theMailbox
    end repeat
end tell

如果您只希望它影响一般收件箱:

tell application "Mail"
    repeat with theMessage in {messages in inbox where read status is false}
        set theMailbox to mailbox "destination" of account "my-account"
        move theMessage to theMailbox
    end repeat
end tell

保存此服务。然后,在系统偏好设置 » 键盘 » 键盘快捷键,为此服务创建一个新的键盘快捷键。

您已经完成。


* 您可以在邮件偏好设置中找到帐户名称,然后在帐户,参见描述线。

答案2

您可以使用 Automator 解决方案通过以下 AppleScript 块创建服务,它将询问您要将选定的消息移动到哪里。

use Mail : application "Mail"
use scripting additions

on findMailBox for partialName
    --display dialog "Looking for mailbox with text " & partialName
    set allMailBoxes to mailboxes of account "Apple"
    repeat with m in allMailBoxes
        if ((offset of partialName in (name of m as string)) ≠ 0) then
            return m
        end if
    end repeat
end findMailBox

display dialog "Destination: " default answer ""
set destinationName to the text returned of the result

set moveTo to findMailBox for destinationName

set theSelection to selection of Mail
repeat with m in theSelection
    --display dialog "will move message " & (id of m as string) & " to mailbox " & (name of moveTo as string)
    move m to moveTo
end repeat

答案3

我正在寻找相同的解决方案,将消息移动到一个文件夹并使用字典,我发现这在 Yosemite 中有效。

tell application "Mail"

  set the_messages to selection
  repeat with this_message in the_messages
 set theSender to sender of this_message  
move this_message to mailbox "BILL PAY/Mortgage & HOA" of account "iCloud" -- a folder        contained by another folder

 end repeat
end tell 

答案4

在 Mavericks (Mail 7.3) 中不再有效

这确实:


tell application "Mail"
    repeat with theMessage in (every message of (mailbox "current" of account "my-account"))
        set mailbox of theMessage to mailbox "destination" of account "my-account"
    end repeat
end tell

相关内容