Adding a signature to a message in "Mail" produces error

Many years ago, probably still under OS El Capitan, I had a beautifully working Applescript for sending mails with Apple’s Mail. When I wanted to re-use it now (under OS Mojave), the line

set message signature of Mitteilung to signature Unterschrift
(where “Mitteilung” is the message I want to send and “Unterschrift” is the name of a signature defined in Mail.)

produces this error Message (my translation from German): “Mail” has received an error: error in the Apple-Event-Routine.

Why is this not working any more? What would be the proper syntax under current OS versions (I will move up to Catalina shortly)?
Thanks for help! Tom

Model: MacBook Pro 13" 2017
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

  1. Go to Mail.app preferences and add at least 1 signature.
  2. Then, use this signature forever:

-- GET existing signatures of my Mail.app
tell application "Mail" to set existingSignatures to signatures
---> {signature "Signature #1"}

-- MAKE new outgoing message with signature
tell application "Mail"
	activate
	set the new_message to (make new outgoing message with properties {visible:true, content:" "})
	tell new_message to set message signature to (item 1 of existingSignatures)
end tell

Hello

Thanks for trying to help me. But I’m afraid your advice did not help. The message is created but although there are 4 defined signatures for the respective Mail-account, none is added and the error message is:
“„Mail“ hat einen Fehler erhalten: Fehler in der AppleEvent-Routine.” number -10000
(my translation: “„Mail“ has received an error: error in the AppleEvent-Routine.” number -10000)

Too bad!
Regards, Tom

You should upgrade to Catalina. The previous OS versions has bug with signature. On the Catalina the problem is fixed.

Thanks for the hint, although it doesn’t help me at this moment. The script is called from an app (RagTime) which I am using for most of my computer work but which is not yet Catalina-compatible. All its users are hoping for the upgrade in the near future.

Regards, Tom