Help with mother's day script

Sadly, as you can see, this is already overdue. I’ve gotten chunks of this to work, but something is eluding me. Here’s the script so far:

on run
	tell application "Finder"
		
		set sourceFolder to alias "Macintosh HD:Users:mftkoehler:Pictures:photos4K"
		set targetPic to some item of sourceFolder
		display dialog "I picked " & targetPic
		
		tell application "Messages"
			
			activate
			set targetService to 1st account whose service type = iMessage
			#send to self
			set targetBuddy to participant "16501234567" of targetService
			#set targetPic to alias "Macintosh HD:Users:mftkoehler:Pictures:Mia_cherry.jpg"
			send file targetPic to targetBuddy
			
		end tell
	end tell
	
end run

I get the following error: error “Can’t make «class docf» "egk2 - 4.heic" of «class cfol» "photos4K" of «class cfol» "Pictures" of «class cfol» "mftkoehler" of «class cfol» "Users" of «class sdsk» of application "Finder" into the expected type.” number -1700 from «class docf» “egk2 - 4.heic” of «class cfol» “photos4K” of «class cfol» “Pictures” of «class cfol» “mftkoehler” of «class cfol» “Users” of «class sdsk»

I’ve tried a number of things to track down the problem. The script correctly picks a different file from the folder each time. If I uncomment the line that directly identifies the jpg, everything works. Somehow the file I select in the Finder is the incorrect type to pass on to iMessage. Help?

Indeed, you’re right.

First of all welcome to the forum.

targetPic is a Finder file specifier which Messages doesn’t know. But the error should occur already in the display dialog line because a string is expected. You have to coerce the specifier to the expected type(s).

The run handler is not needed and path to pictures folder is the relative path to your Pictures folder.
Further it’s bad practice to nest tell application blocks.

set picturesFolder to (path to pictures folder)
tell application "Finder"
	set targetPic to some item of folder "photos4K" of picturesFolder
	display dialog "I picked " & (name of targetPic)
end tell
tell application "Messages"
	activate
	set targetService to 1st account whose service type = iMessage
	#send to self
	set targetBuddy to participant "16501234567" of targetService
	send (alias (targetPic as text)) to targetBuddy
end tell