Make a Things reminder out of Mail message

Hello everyboby,

I’m trying to cut out some text from a Mail message. The script is triggered by a Mail’s rule. But the script is not working. Maybe you can help me. Here’s the script:


--TrimFunctions
on trimText(find, subject)
	set prevTIDs to text item delimiters of AppleScript
	set text item delimiters of AppleScript to find
	set subject to text items of subject
	
	-- set text item delimiters of AppleScript to replace
	try
		set subject to last item of subject
	end try
	set subject to "" & subject
	set text item delimiters of AppleScript to prevTIDs
	
	return subject
end trimText

on cutText(find, subject)
	set prevTIDs to text item delimiters of AppleScript
	set text item delimiters of AppleScript to find
	set subject to text items of subject
	
	-- set text item delimiters of AppleScript to replace
	try
		set subject to first item of subject
	end try
	set subject to "" & subject
	set text item delimiters of AppleScript to prevTIDs
	
	return subject
end cutText

-- Boilerplate code for Mail Rules
using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		
		
		-- Script Starts Here
		
		
		-- Repeat the following actions for every email matched by rule
		repeat with eachMessage in theMessages
			
			-- Get the emails content
			tell application "Mail" to set theContent to content of eachMessage
			set theContent to trimText("~", theMessageText)
			set theContent to cutText(linefeed, theMessageText)
			set theContent to trimText(". ", theMessageText)
			
			tell application "Things"
				set newToDo to make new to do ¬
					with properties {name:"Casamail  - " & theContent} ¬
					at the beginning of area ¬
					"Haushalt"
				
				set tag names of newToDo to "zuhause 🏡"
				--set notes of newToDo to theMessageText
				
				
				move newToDo to list "Today"
			end tell
			
			
			
			
			-- Delete the mail
			--delete eachMessage 
		end repeat
		
		
		-- End script and close boilerplate section
	end perform mail action with messages
end using terms from

Hi,

the variable theMesssageText is not defined.
Try to pass the variable theContent


.
set theContent to trimText("~", theContent)
set theContent to cutText(linefeed, theContent)
set theContent to trimText(". ", theContent)
.

Hi,

thank you! Now it works!