Hi schulzmc - I had posted a similar reply to this a little while ago but I think I missed a message from MacForum saying that I was apparently not logged on so my first shot may not have been posted - if you see two replies what the heck - they both say similar things ...
I tried several ways to make this work but each attempt crashed Mail - the problem arises when the script tries to generate a new message. If you use the code sample shown below (all this does is to strip out the ""tt" from the subject of the email and put the remaining string into a dialog box for you to see) you can see that the email is held back until you click the OK button. (I tested this by sending an email to myself with "tt" in the subject).
If you remove the dialog display and try to create a new message it crashes Mail. Mail still crashes even if you put the new message creation code at the end of the script, - I think this is because the script suspends Mail - but then the script tries to make a new message - it can't suspend Mial and try to make it create a new message at the same time!
My script:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
set myString to subject of eachMessage
set i to count of myString
set subjectString to text from word 2 to i of myString
display dialog subjectString
end repeat
end tell
end perform mail action with messages
end using terms from
You might have to get round this by splitting the job in two i.e. trigger a script from the rule that catches each message with "tt" in the subject and puts them into a mailbox. You could then open one of the messages and then run a separate script (using the script folder utility on the top menu bar) to take the subject, strip out the "tt" and make a new message and insert the remaining string into the new subject.
Other things you might try is to use the "reply" or "forward" methods to create new messages in the script above but I suspect these will cause Mail to crash as well. If you deviate from the "using terms from ...." & "on perform mail action etc ... " format the script never gets triggered so scope for invention is a bit limited.
Applescript can be downright annoying at times - you would never guess the syntax used above from the dictionary for Mail, I gleaned some of this from the Apple website and the O'Rielly book "Applescript - The definitive Guide" - I thought I had this nailed but then Mail got all grumpy and that was that.
If you manage to get this working I would be interested to see the script / method.