Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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...

share|improve this question

5 Answers 5

up vote 3 down vote accepted

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

share|improve this answer

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

share|improve this answer
    
I never thought of using AppleScript. I kind of assumed there must be a "native" solution. Your suggestion works perfectly. I used the FastScripts approach, since I already have FastScripts. I would never have figured out how to do it in AppleScript! –  hibbelig Oct 19 '11 at 4:20
    
Actually, there is a way to do it without AppleScript I missed when answering at first, but it involves using commercial software – see my addendum to the answer. –  kopischke Oct 19 '11 at 13:10

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.

share|improve this answer
    
As mentioned in the original question, I had tried that, but instead of applying the flag, it changed to the folder, when I pressed the key. Not sure why it is behaving differently for you than me. –  hibbelig Nov 11 '12 at 19:34
    
This only works if you don't have the flagged folder in your favorites. The reason is that the first menu item "Orange" will match is Mailbox, Go to favorite, Orange. –  Fuzzy76 Feb 1 '13 at 14:12
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.)

share|improve this answer

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
share|improve this answer
    
The problem is that I've added the folder in question to my favorites. And I like it that it is in my favorites: this way I can easily see how many messages I've flagged. –  hibbelig Dec 4 '13 at 13:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.