Selecting an Apple Mail mailbox

Hi there

Am using Apple Mail with an IMAP account. I want to hook an applescript up to a Mail Rule and invoke it via a Mail Act-On shortcut.

I want to be able to select my archive mailbox which in IMAP terms is INBOX.archive via applescript

I have this code:


tell application "Mail"
  set selected mailboxes of message viewers to {archive}
end tell

but am told that the variable ‘archive’ does not exist, or if I try “archive” instead of {archive} get an AppleEvent Handler failed error.

How to reference my INBOX.archive folder so that I can open it via applescript?

Hi,

try this


tell application "Mail"
	set selected mailboxes of message viewer 1 to {mailbox "archive" of imap account "myAccount"}
end tell