Here’s a script to rename emails (or other stuff with a subject):
tell application id "com.devon-technologies.thinkpro2"
set theSelection to the selection
repeat with theRecord in theSelection
try
set theMD to meta data of theRecord
set theSubject to |kMDItemSubject| of theMD
set name of theRecord to theSubject
end try
end repeat
end tell