AppleScript and mail

I have an AppleScript that I use to change the background colour of selected messages in Apple Mail.
The script works but Apple Mail does not update the colour straight away, you need to come off the message go back on and then off again. Also if I close the application and then reopen, the message has the correct colour setting - it is as if Apple Mail needs a “refresh” to update settings!

Has anyone else had any experience of this, or any thoughts of how to get round this as it is a bit of a pain…

Thanks
Scott

Hey Scott,

Yes, I’ve seen this.

No – there’s no way around it that I’m aware of. (Bad Apple!)

-Chris

Thanks - Its good to know it is not just me !

Scott

Hey Scott

Would you mind sharing that script here? Sounds kind of useful. :slight_smile:

Just change the background color property of a message. As for how to get Apple Mail to refresh, this sort of works:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Mail"
	set saveSelection to selection
	repeat with aMessage in items of saveSelection
		set background color of aMessage to orange
	end repeat
	set selected messages of message viewer 1 to saveSelection -- force a refresh...
end tell