5

One of the flags in Apple Mail can be applied to a message using Command-Shift-L. Is there a way to apply any other flag?

I renamed one of the colors to TODO, and I set up a keyboard shortcut for the TODO menu item in Apple Mail, using System Preferences. When I used this keyboard shortcut, Mail switched to the TODO folder...

kopischke
  • 2,256
hibbelig
  • 185

5 Answers5

5

Mail.app flags are accessible via AppleScript in the flag index property of the message object. The index starts at 0 (-1 meaning “no flag”), counting up in the order in which flags are listed in the Mail menu. You can either create a pure AppleScript:

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 <index>
    end repeat
  end if
end tell

and assign it a hotkey through a launcher application like FastScripts, or embed it into a system service, by creating a Service Automator workflow set up to:

  • take no input (!)
  • in Mail.app

with the first item a “Get Selected Messages” action, followed by a “Run AppleScript” action with the following code:

on run {input, parameters}
  set selectedMessages to input
  tell application "Mail"
    if (count of selectedMessages) is greater than 0 then
      repeat with theMessage in selectedMessages
        set flag index of theMessage to <index>
      end repeat
    end if
  end tell 
  return input
end run

You can then assign a hotkey to your newly created service in the System Preferences, Keyboard settings:

screenshot

ADDENDUM: if you prefer a pure GUI solution, you can also use MailActOn by Indev Software. Using MAO, you can setup a MailActOn rule (in Mail’s Rules setting panel, which MAO extends) to assign the flag. If you give that rule a unique MAO trigger letter and make sure the “Control+ActOn key applies rule” setting int the MAO preferences is checked, you can assign the flag to any selected mail with Ctrl+<trigger letter>:

screenshot

Gareth
  • 19,080
kopischke
  • 2,256
3

Here's a method that is much easier in that it uses only the System Preferences (no scripting or third party software needed):

  • Open System Preferences > Keyboard > Keyboard Shortcuts
  • Click "+" to add a new shortcut
  • For Application, choose Mail from the drop down (to avoid conflicts in other applications)
  • Enter the Menu Title as it appears in Mail (Red, Orange, Clear Flag, etc.)
  • Enter the desired keyboard shortcut for that menu option (I use option+R, option+O, etc.)
  • Click Add
  • Repeat for as many color flags as you like

No muss, no fuss! Since flag color menu choices are unique and by assigning the shortcuts only to the Mail app, hard to see how it could cause any unwanted side effects. Works like a charm in Mail 5.3 and OS X 10.7.5, can't vouch for older versions.

3

The problem is that your flag's name was the same as a folder's name. For the shortcut to work, the flag must be unique in Mail.app's menu items. Since folder names are navigable to via the menu system, it is conflicting with your flag name.

I know you've accepted an answer, but another easier solution would have been to name your flag something like "@TODO", "TODO!", etc... I use "@Flag Name" for all my flags and it works like a charm.

See: Link to my Message->Flag menu with shortcuts

Article Describing Configuring short cuts: Making OS X Lion Mail.app Flags more useful

0
try
    tell application "Mail"
        repeat with m in (get selected messages of message viewer 1)
            set flag index of m to 4
        end repeat
    end tell
end try

-- 0: none, 1: red, 2: orange, 3: yellow, 4: green, 5: purple, 6: gray

And Assign a shortcut to running a script in OS X - Super User (I.e. use FastScripts, as the OP already seems to do.)

Lri
  • 42,502
  • 8
  • 126
  • 159
0

The above solution worked for me like a charm in Mavericks

Here's a method that is much easier in that it uses only the System Preferences (no scripting or third party software needed):

  • Open System Preferences > Keyboard > Keyboard Shortcuts
  • Click "+" to add a new shortcut
  • For Application, choose Mail from the drop down (to avoid conflicts in other applications)
  • Enter the Menu Title as it appears in Mail (Red, Orange, Clear Flag, etc.)
  • Enter the desired keyboard shortcut for that menu option (I use option+R, option+O, etc.)
  • Click Add
  • Repeat for as many color flags as you like
Andrea
  • 1,536
rochak
  • 1