Did you include the mail rule handler in your script? It's always better to share the code or part of your code that isn't working to help and understand the problem better. It's now like "my car won't start" and we have to guess what could be wrong.
There are however some parts that are important to work properly:
1- Did you include the perform mail action with messages
handler? This handler, or in this case event, must be included to the script, it's starting event for the mail rule to trigger inside your script. It doesn't run
your script when an script is set as an mail rule action.
using terms from application "Mail"
on perform mail action with messages message_list in mailboxes mbox for rule a_rule
tell application "Mail"
display dialog "You've got " & (count of message_list) & " new mails"
end tell
end perform mail action with messages
end using terms from
3- In Mountain Lion and higher the script needs to be saved in the ~/Library/Application Scripts/com.apple.mail folder to work.
There are AppleScript mail rule issues in Mountain Lion but are solved in Mavericks. I think they only applied to pop3 mail boxes and not imap accounts