Hi,
I was trying to get Mail to perform the following:
-copy mails from a certain source in to a couple of submailboxes according to keyword content
-then highlight the keywords that triggered the copy with certain colors
The first is obviously easy using just rules. For the second I have attempted the following script:
using terms from application "Mail"
on perform mail action with messages message_list for rule this_rule
set targetdir to name of (copy message of this_rule)
repeat with this_message in message_list
if targetdir is equal to "workspace" then
set numberofwords to 2
set targetwords to {"bugger", "test"}
set markingcolor to {red, blue}
end if
set WordCount to (count words of content of this_message)
--display dialog "WordCount: " & WordCount buttons {"OK"} default button 1 with icon stop
repeat with counter from 1 to WordCount
set currentword to word counter of content of this_message
repeat with counter2 from 1 to numberofwords
set comparisonword to item counter2 of targetwords
if currentword is equal to comparisonword then
display dialog "triggered! " buttons {"OK"} default button 1 with icon stop
set color of word counter of content of this_message to red
-- later plan: set color of word counter of content of this_message to item counter2 of markingcolor
--test:
set currcol to color of word counter of content of this_message
display dialog "currcol! " & currcol buttons {"OK"} default button 1 with icon stop
end if
end repeat
end repeat
end repeat -- message loop
end perform mail action with messages
end using terms from
It seems to work mostly as anticipated, except that setting the color does not seem to have any effect.
Can I just not do this at all? Or do I do it wrong?
Thanks in advance for any help,
Sebastian
Model: MacBookPro
AppleScript: 2.1.2
Browser: Firefox 5.0
Operating System: Mac OS X (10.6)