I am constantly getting emails of the form "Node status bad", "Node status ok", "Node status unknown" and I would like to know, for example, if an email of the form "Node 3 status bad" came in and then 20 minutes later "Node 3 status ok" came in, how to mark them both as 'read'.

I am pretty good at commandline scripting and was wondering where these files are located in my directory structure. I can easily write a script to parse the files and search for keywords, etc. - I'm not worried about that - I'm just wondering:

(1) what folder/directory are these emails stored in (on my local system)


(2) Is there a way to mark them as 'read' from commandline? That way I can script that command to these files automatically under certain conditions.


I suspect that your answer here will be mail rules, and AppleScript. Rather than relying on parsing out the raw messages, you can create a rule to filter on the bad status messages and then run an AppleScript, and another on the Ok.

To learn about AppleScript and the Mail dictionary: enter Introduction to Scripting Mail

Mail rules are set in Preferences on the Rules tab.

AppleScripts for mail are installed in $HOME/Library/Application Scripts/com.apple.mail/ Helpfully, when you choose AppleScript from the rules dropdown it'll give you the option to open that folder.

You can probably accomplish this with a single script, run when an OK message is received, to check the inbox for bad messages and mark them as read, along with the current message.

Assuming you mean shell scripting by command line, which is comparable to AppleScript - if anything AppleScript is easier, being designed to be English-like and quite readable.

To view the available commands in AS for Mail.app you can open Script Editor (Applications/Utilities), then File->Open Dictionary. Open the Mail dictionary for the command reference guide.

Alternatively, you can try this the *nix way here, but, on a Mac, the Mac way is often easier.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .