Scripting Messages in Monterey, can't send images

Hello all,
I had a script that could send images as well as text messages via Messaages but after upgrading to Monterey it won’t send the images anymore. For example:


tell application "Messages"
	activate
	set targetService to 1st account whose service type = iMessage
	set targetBuddy to participant "1234123123" of targetService
	send myAlias to targetBuddy
end tell

myAlias is a JPEG and not particularly large. The script does not produce an error. Messages tries to attach the image as a downloadable file but then fails after some time. If I do it manually by dragging and dropping the JPEG into Messages, it has no problem and sends the image.

I might have to fall back on UI scripting. The current conversation can be activated via AppleScript; then the Buddies/Send File command and locating the file can be done by System Events. I’ll post the code later.