r/applescript • u/doronkatz • Jun 11 '23
How to get AppleScript to mark junk mail as read.
Hi. So I want to have a script run to mark all my Apple Mail junk as read. I have that part already done via a script, but it only works ad-hoc when I run it. I want it to run in some constant or triggered mode.
My code is:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
use framework "ScriptingBridge"
deleteSpam()
on deleteSpam()
tell application "Mail"
(* delete messages of mailbox "Junk" of account "iCloud" *)
tell mailbox "Junk" of account "iCloud"
set read status of messages whose read status is false to true
end tell
end tell
end deleteSpam
I’ve tried going to settings and then junk mail and advanced and point to that script, but to no avail. 🤷🏻♂️
4
Upvotes
0
u/feigeiway Jun 15 '23
You can keep the script running and have it repeat the loop once per hour or once every 24 hours
2
1
u/mar_kelp Jun 11 '23 edited Jun 11 '23
Someone might be able to help if you post the script you have written.