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:

  1. tell application "Mail": This line tells AppleScript to interact with the Mail application.
  2. set currentMessage to current message: This line sets the currentMessage variable to the currently selected message in Mail.
  3. set previousMessage to (currentMessage's previous message): This line sets the previousMessage variable to the message that was previously selected in Mail. The previous message property is a built-in property of the message object in Mail.
  4. 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:

  1. Open Mail and select the message you want to move.
  2. Go to the "Window" menu and select "Show Script Menu" (or use the keyboard shortcut Cmd + Shift + S).
  3. In the script menu, select "Move to Previous Message".

This will move the selected message to the previous message in the conversation.