Trouble scripting FileMaker from a Mail script

OK, I need help. (I’m with FileMaker Pro 5 and Mail 2.1)

I have this script that runs perfectly well when I call it from my on run() function

on logText(logItem)
	tell application "FileMaker Pro"
		open file "Throll:Users:pat:Databases:ErrorLog.fp5"
		set myRecord to create new record
		set cellValue of cell "Description" of myRecord to logItem
	end tell
end logText

It tells FileMaker to open the file “ErrorLog.fp5”, create a new record and add some text into a field. Nothing much to worry here… What I want is to put something in a “log” database when a specific kind of email is received from my web site.

The problem is, when I call the logText function from a perform_mail_action function like this :

on perform_mail_action(info)
	tell application "Mail"
		set theMessages to |SelectedMessages| of info
		repeat with thisMessage in theMessages
				my logText("This is my error message")
		end repeat
	end tell
end perform_mail_action

The “Open” call (in logText) generates an error and refuses to log correctly my comment, wich is bad for my log… Is there something wrong with my perform_mail_action? Is it possible that an Open file statement can’t go in a script that’s called from Mail?

Help!