Calling extension within tell block

This code used to work just fine:

...
set theContact to grep("^Client Name:\\s+(.*)\\n", theContent, "\\1", {})
...

on grep(findThis, inThis, returnThis, regex_flags)
	try
		return find text findThis in inThis using returnThis regexpflag regex_flags with regexp and string result
	on error errMessage number errNumber
		if errNumber is equal to -2763 then
			return ""
		else
			display dialog (errMessage)
		end if
	end try
end grep

Once I put the first section of code inside a tell block…

tell application "Mail"
...
set theContact to my grep("^Client Name:\\s+(.*)\\n", theContent, "\\1", {})
...
end tell

…I get an error '“^Client Name:\s+(.*)\n” doesn’t understand the <> message. Please note that “find text” is provided by the Satimage scripting extension.

What am I missing?

Hello.

It seems like satimage events aren’t resolved within the mail.app block, I think this is a security measure. What you can do to try to resolve it, is to wrap your handler inside a tell me block, instead of calling it with my.

hth

That was it! Thank you for your advice.