Simple Move of Messages from One Mailbox to Another

I am trying to move all messages in one mailbox (Counter 1) in an account to another (Counter 2). I can do it message by message but am looking to what would seem to be the more elegant solution of using ‘every message’. However I am getting an issue with AppleScript recognising the mailbox.

The AppleScript is (substitute the account for email@domain)…


tell application "Mail"
	activate
	set AccountToBeUsed to "email@domain"
	set Counter1Mailbox to "Counter 1"
	set Counter2Mailbox to "Counter 2"
	
	set Counter1Location to mailbox Counter1Mailbox of account AccountToBeUsed
	set Counter2Location to mailbox Counter2Mailbox of account AccountToBeUsed
	move every message of mailbox Counter1Location to mailbox Counter2Location
end tell

The error I get is…

error “Mail got an error: Can’t make mailbox "INBOX/Counter 1" of account id "72A44363-AE52-4429-AC99-AC1A4AA79B17" into type integer.” number -1700 from mailbox “INBOX/Counter 1” of account id “72A44363-AE52-4429-AC99-AC1A4AA79B17” to integer

I am sure that I am doing something rather stupid but can’t figure it out.

Thanks for any help.

Model: MacBook Pro (Retina, Mid 2012)
AppleScript: 2.7
Browser: Safari 537.36
Operating System: macOS 10.14

Both Counter1Location and Counter2Location are already references to mailboxes. Remove the keyword mailbox


move every message of Counter1Location to Counter2Location

Ooops! :frowning:

Thanks, Stefan!

Model: MacBook Pro (Retina, Mid 2012)
AppleScript: 2.7
Browser: Safari 537.36
Operating System: macOS 10.14