Move mail message back to inbox of Exchange account

applescriptemailexchangemail.app

Is there a special syntax for using AppleScript to move a message from a folder back into the inbox of an Exchange account?

I have Apple Mail configured with three accounts, two Gmail accounts and an Exchange account. The code below should move the selected message to the inbox of its respective account. It works as expected for the Gmail accounts; but, returns an error for the Exchange account:

set theSelection to selection

# do nothing if no email is selected in Mail
try
    set theMessage to item 1 of theSelection
on error
    return
end try

set theAccount to account of mailbox of theMessage
set UnSnoozeBox to mailbox "INBOX" of theAccount            
move theMessage to UnSnoozeBox

Specifically, when I try to set UnSnoozeBox, I get `The action “Run AppleScript” encountered an error: “Mail got an error: Can’t get mailbox "INBOX" of account id "80403C8B-7G0H-4CCA-D619-3605F76138F1".”

(For what it's worth, the code that moves messages into the "Snooze" folder works as expected for all three accounts.)

Best Answer

I figured it out: It's 'Inbox' for Exchange, and "INBOX" for GMail. (How annoying.)