Monterey - Adding Contact to a Group


Just installed the RC of Monterey and have run into an issue with one of my scripts that worked fine on Big Sur.

I can select an email in Apple Mail and create a contact from the sender but get an error when trying to add the new Person to an existing Group. The error that comes up is “You can only add a person to a group”

I won’t post my script here as it is quite long but in the script below the same issue occurs.

Any ideas on how to correct this are most welcome.


tell application "Mail"
set theMessages to selection
if theMessages is not {} then -- check empty list
	set theSenderName to extract name from sender of item 1 of theMessages
	set nameArray to my split(theSenderName, " ")
	set theFirstName to item 1 of nameArray
	set theLastName to last item of nameArray
	set theEmail to extract address from sender of item 1 of theMessages
	tell application "Contacts"
		set theGroup to group "_TEST"
		set thePerson to make new person with properties {first name:theFirstName, last name:theLastName}
		make new email at end of emails of thePerson with properties {label:"Work", value:theEmail}
		add thePerson to theGroup
	end tell
end if
end tell

on split(theString, theDelimiter)
	set oldDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	set theArray to every text item of theString
	set AppleScript's text item delimiters to oldDelimiters
	return theArray
end split