Applescript move to previous message in mail
A nice AppleScript question!
To move to the previous message in Mail using AppleScript, you can use the following script:
tell application "Mail"
set currentMessage to current message
set previousMessage to (currentMessage's previous message)
move previousMessage to mailbox "Inbox"
end tell
Let me explain what this script does:
tell application "Mail"
: This line tells AppleScript to interact with the Mail application.set currentMessage to current message
: This line sets thecurrentMessage
variable to the currently selected message in Mail.set previousMessage to (currentMessage's previous message)
: This line sets thepreviousMessage
variable to the message that was previously selected in Mail. Theprevious message
property is a built-in property of themessage
object in Mail.move previousMessage to mailbox "Inbox"
: This line moves the previously selected message to the "Inbox" mailbox.
To use this script, save it as an AppleScript file (e.g., Move to Previous Message.applescript
) and then run it using the AppleScript Editor application or by double-clicking the file.
Alternatively, you can also use the move to previous message
command in the Mail application's script menu. To do this:
- Open Mail and select the message you want to move.
- Go to the "Window" menu and select "Show Script Menu" (or use the keyboard shortcut
Cmd + Shift + S
). - In the script menu, select "Move to Previous Message".
This will move the selected message to the previous message in the conversation.