Use Applescript to flag or color a mail message

I have written an applescript that I invoked with a hot key that takes a mail message and its attachment and saves it in a folder I select. At present asks me if I want to delete it but sometimes I don't. I have been trying to work out a way to either flag the message or color the line in preview so I know I have processed it. so far no success any ideas please.


I realise that a mail rule will do this but I do not know how to call a rule from the script.

Peter

iMac 27" PC. Macbook Pro, Mac OS X (10.6.4)

Posted on Jul 11, 2011 11:56 AM

Reply
8 replies

Jul 11, 2011 1:13 PM in response to Don Archibald

Don


No I did not explain myself properly. I want to leave some messages in mail (for threads etc) but mark it so I know I have processed it either with a flag or color. As I mentioned I have given myself the option of deleting the message when it has been processed. But if I do not delete it I sometimes process it again and that is what I am trying to avoid.


I had though about creating a rule then deleting it but that has me stumped as well.

Jul 11, 2011 1:34 PM in response to MitchBVI

I don't know how addressable Mail is via AppleScript, but it does have a color menu in its header. With a message selected in the upper-panel list, selecting a color from that menu will flag/color the message in the list with that color (very similar to lFinder's labelling function, in appearance anyway).


One of the display variants for that color menu is Web Safe Colors, which should allow entering a color code.


The sequence, in actions - select the message; open Color menu; select a color; close menu.


The Color menu/window can be opened via keyboard command: Command-Shift-C


*****


Alternatively, you could reserve the "Flag" indicator available in Mail for just this purpose. It's in the Message menu, in the Mark submenu. Via keyboard, it's Command-Shift-L which should allow easy inclusion in your AppleScript.

Jul 11, 2011 1:56 PM in response to Don Archibald

Don


Cannot find "color menu in its header" where exactly do you mean in applescript or mail".


I have tried this trial scrip as I thought your idea of command shift L would work. the scrip compiles and runs OK just does not flag the message selected.


tell application "Mail"

set themsg to selection

set themsg to item 1 of themsg

tell application "System Events"

tell process "mail"


keystroke "L" using {command down, shift down}

end tell

end tell

end tell


this is the event log

tell application "Mail"


get selection


--> {message id 32232 of mailbox "INBOX" of account "MobileMe"}

end tell

tell application "System Events"


keystroke "L" using {command down, shift down}

end tell

Can you see what i am doing incorrectly and thank you for your time.


Peter


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Use Applescript to flag or color a mail message

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.