Filing/Moving IMAP Emails with AppleScript

I’ve trying to write and AppleScript to help me more swiftly file emails to commonly used folders.

Here is the script I have so far:

tell application "Mail"
	set theSelectedMessages to selection
	repeat with theMessage in theSelectedMessages
		set theMailbox to "[Gmail]/Person Mails"
		tell application "Mail"
			move the theMessage to mailbox theMailbox of account "Gmail"
		end tell
	end repeat
end tell

This fails, however, with the error "Mail got an error: Can’t get mailbox “[Gmail]/Personal Mails” of account “Gmail”

Is this because I’m using an IMAP account or have I somehow missed something in the syntax?



Try this

change the line
set theMailbox to “[Gmail]/Person Mails”

set theMailbox to “Personal Mails”

That should work.

Thanks, Prince!

That did the trick!

Much appreciated,