Sonoma Mail Bug? Can someone confirm?

I am not yet running Sonoma, but I have someone who I wrote a script for update their machine to Sonoma and now the script isn’t doing what it should be doing. The script below should take the selected email messages, and move them to the Archive folder (as written this would be used with an iCloud inbox and the iCloud Archive folder. For whatever reason, Mail in Sonoma does not actually MOVE the message. The message will appear in the Archive folder after you have run this script, but as soon as you delete the message from the Inbox, it deletes the “copy” in the Archive maibox as well. This does not happen on Ventura.

tell application "Mail"
set archiveMailbox to mailbox "Archive" of account "iCloud"
set theMessages to selection
repeat with theMessage in theMessages
	move theMessage to archiveMailbox
end repeat
end tell

If you are running some version of Sonoma, do you see tis problem as well, where the message is not moved, and when you delete the version in the Inbox, the “copy” gets deleted from the Archive mailbox as well?

I have not yet tried to duplicate the message to the archive folder, and then delete the version in the inbox, and see if the Archive folder version also is deleted. That might be the workaround if this is indeed a bug with moving Mail messages in Sonoma.

Thanks

I’m on Sonoma 14.2 and am not seeing this issue. Running the script you provided moves the selected emails into the Archive and they no longer appear in the Inbox. The messages stay archived after quitting & reopening Mail.

The script also works for me on Sonoma 14.2. (And it’s very useful - thank you for it.)