creating rules for mailboxes by apple script

Dear Apple friends ,

I am writing an apple script in which rule for each mailbox has to be created . The script is looping through all mailboxes , it has to check whether there is rule existing for the mailbox , if not create a rule for the existing box. The simple rule is if a when mail message is recieved from particular sender_name@domain_name transfer that mail to this this mailbox .Any help or clue to where I can get the answer will be highly appreciated . Is there is also any way to add the rules to the existing rules .

   The other part of the script is working fine , I just want to know how to add rule to this particilar mailbox in a loop . The version of the mail application is 2.1 . 

Thanks in advance

Krishna

If you check the Mail dictionary (in Script Editor) you’ll see that rules aren’t an element or property of the mailbox class. This means that looping through the mailboxes won’t work.

However, since rules are a class of their own, you can use:


tell application "Mail"
	repeat with myRule in (every rule)
		(*check what mailbox the rule is for and do what you need to do*)
	end repeat
end tell

This should be enough to get your started, post back if you need more help.