Use a simpler script:
tell application "Mail"
set the theMessage to item 1 of (get selection)
set theID to the message id of the theMessage
end tell
set theURL to "message:%3C" & theID & "%3E"
set the clipboard to theURL
Use a simpler script:
tell application "Mail"
set the theMessage to item 1 of (get selection)
set theID to the message id of the theMessage
end tell
set theURL to "message:%3C" & theID & "%3E"
set the clipboard to theURL
python is no longer part of macOS base, you have to install the Command-line Tools, and you will have to use python3 instead of python. I don’t think the script needs to change.
xcode-select --install