Is it possible to quickly clear flags in Apple Mail 6 ( probably with AppleScript)

mail.app

I'm running Apple Mail 6.2 on OS X 10.8.2.

I'm wondering how to clear flags easily, maybe a button exists or a shortcut is possible? Currently I need to press the down arrow in flag button and click "clear flag", which is really inconvenient.

I think AppleScript is highly promising, but I don't know how to do it.

Best Answer

According to this thread, copy below script into Apple Script Editor and then run

tell application "Mail"
set selectedMessages to (selected messages of front message viewer)
if (count of selectedMessages) is greater than 0 then
    repeat with theMessage in selectedMessages
        set flag index of theMessage to 1
    end repeat
end if
end tell

Your selected message will flag with Orange. You can flag message with other color by replacing 1 in the script