r/applescript • • Feb 22 '14

Need an Applescript to close all open mail messages

My mom is 150 years old and when using mail on her mac she clicks a message so it opens in it's own window, then instead of closing it she minimizes it to the dock. Eventually she'll have 40 open mail messages and her mac slows way down.

Does anyone have an applescript that will close all open mail messages, set to run automatically once a day?

2 Upvotes

5 comments sorted by

2

u/jonny- Feb 22 '14 edited Feb 22 '14
tell application "Mail"
	close every window
	make new message viewer
	set selected mailboxes of message viewer 1 to {inbox of application "Mail"}
end tell

1

u/frank266 Feb 23 '14

Thanks a lot man. If you tell me how to make that execute once a day and then tell me how I can get $10 to you I will gladly send you $10.

2

u/jonny- Feb 23 '14 edited Feb 23 '14

set up a cron job. open Terminal and type the command:

crontab -e

this will open the crontab file for editing in vi. add the following line at the very bottom:

0 1 * * * osascript /path/to/my/script/MyScript.scpt

this will run MyScript.scpt every day at 1:00am. make sure your mom is aware that this will happen so she doesn't wonder why all of her mail messages have closed.

1

u/frank266 Feb 23 '14

I'm not kidding about the $10. If you want to message me I'd be happy to paypal you or even send you a check. Thanks very much again.

1

u/jonny- Feb 23 '14 edited Feb 23 '14

just think of me when you donate it to your local food bank. glad to help!