I’m using Tiger, and Mail.app, and I’d like to add a rule that uses an Applescript
to change the encoding of certain messages (with subject starting in LL-L) automatically.
I first experimented to get the encoding part: I didn’t see it in the scriptable stuff in Mail, so
I used GUI-scripting instead:
tell application "Mail" to activate
tell application "System Events"
tell process "Mail"
tell menu bar 1
tell menu bar item "Bericht"
tell menu 1
tell menu item "Tekstcodering"
tell menu 1
click menu item "Unicode (UTF-8)"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
and this works fine as a stand-alone script: the mail is selected and I choose this script from the menu
and it does its job.
Now I added a rule to Mail to execute the following script whenever the subject was as described:
The above is a handler here (subroutine).
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Mail"
repeat with eachMessage in theMessages
select eachMessage
setUTF8()
end repeat
end tell
end perform mail action with messages
end using terms from
on setUTF8()
tell application "System Events"
tell process "Mail"
tell menu bar 1
tell menu bar item "Bericht"
tell menu 1
tell menu item "Tekstcodering"
tell menu 1
click menu item "Unicode (UTF-8)"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end setUTF8
But this doesn’t work. Maybe the “select” part didn’t activate the right message?
I don’t see what’s wrong here, do you?