I agree with twtwtw. Most of the rules I use simply organize the inbox into separate mailboxes. So with a list of 150 or so students each semester, it would be great to have this script work..it creates the rules, one for each student number, but then the rule won't move the incoming messages. Hmm...
So if anyone figues out why, it would be great to let us know!
tell application "Microsoft Excel"
set hpath to "Macintosh-HD:Users:bg:20f11:Hmwk:graded:"
set theGrades to open workbook workbook file name "Macintosh-HD:Users:bg:20f11:20f11_grades.xlsx" update links do not update links
set email_list to value of every cell of range "e_mail"
set theMailbox to "20f11"
activate
set sn to value of every cell of range "sn" --sn is student number
end tell
tell application "Mail"
repeat with j from 1 to length of sn
set newRule to makenewruleat end of ruleswith properties {name:itemj of sn), enabled:false}
tell newRule
makenewrule conditionat end of rule conditionswith properties {rule type:from header, expression:itemj of email_list), qualifier:does contain value, move message:mailboxtheMailbox}
end tell
end repeat
end tell