Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automatically mark messages as read in Trash

How can I mark all deleted messages as read in Apple Mail of Mac OS X?

Mac OS X (10.7)

Posted on Jan 12, 2018 8:16 AM

Reply
Question marked as Best reply

Posted on Jan 13, 2018 3:23 AM

I have found out a suitable answer to my own question. Here is what works for me.


1. Make a script to mark all items in trash as read

- Open Script Editor

- Copy next text in the editor

on run {}

tell application "Mail"

set read status of every message of mailbox "Deleted Items" of account "MyAccount" to true

end tell

end run

- Change "Deleted Items" into the name of your trash folder (keep the quotes). If you don't know the exact name, check below under PS1.

- Change "MyAccount" into the name of your account (keep the quotes). If you don't know the exact name, check below under PS2.

- Test by making sure that you have at least one unread mail in Trash, press run in Script Editor and verify that all mails in Trash are now marked read

- Save the file as a script file (extension scpt) in a location where it does not bother you.


2. Make a launch daemon to schedule the execution of the script

- Open Text Editor

- Copy next text in the editor

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.apple.markdeleteditemsasread</string>

<key>ProgramArguments</key>

<array>

<string>osascWooooWript</string>

<string>/Users/username/MarkDeletedItemsAsRead.scpt</string>

</array>

<key>StartInterval</key>

<integer>180</integer>

</dict>

</plist>

- Delete WooooW from the above text (I had to include it to be able to post this here).

- Change the label value (which is currently com.apple.markdeleteditemsasread). If you own a website, it is a good idea to refer to your domain (instead of apple.com).

- Change the script location to where you have saved the script (which is currently /Users/usrename/MarkDeletedItemsAsRead.scpt)

- Change the interval if desired (it is now set to 180 seconds, which is 3 minutes)

- Save the file to a temporary location. Use the label as name (not sure if this is required, but I guess it is a good practice) and plist as extension (in my case the file name will be: com.apple.markdeleteditemsasread.plist ).


3. Activate the launch deamon

- Open Terminal

- Copy the plist file to /Library/LaunchDaemons, for example:

sudo cp /Users/username/com.apple.markdeleteditemsasread.plist /Library/LaunchDaemons/

- Change the permission properties of the file as follows (makes it a file owned by your admin user that cannot be changed by other users):

sudo chown root:wheel /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

sudo chmod o-w /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- Launch the deamon (see PS3 to find out how to test if it works):

sudo launchctl load /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- Optional: Delete the original plist file if it works (I advise to keep it for a while though for testing, see PS3 below)

- Do not delete the plist file in /Library/LaunchDaemons

- Do not delete the scpt file


Good luck!


Jan Claes


PS1 If you don't know the exact name of your trash folder:

- comment the set-intstruction in your script (by preceding the line with two dashes)

- select an email in your trash (in the Mail app)

- put the command "selection" (without quotes) within the tell-block

- press run

- the name is after mailbox

- your script will look like this

on run {}

tell application "Mail"


--set read status of every message of mailbox "Deleted Items" of account "MyAccount" to true


selection

end tell

end run

- and the output will look like this

{messageid 45452 of mailbox "Trash" of accountid "E7533424-41C1-4AC2-66D6-344C0DB8C2AC" of application "Mail"}

PS2 If you don't know your account name:

- go to Mail

- go to settings (Cmd-,)

- go to Accounts

- check name in overview on the left


PS3 How to test your daemon:

- mark at least one file in Trash as unread

- change the time interval in the original plist file (in my case in /Users/username/MarkDeletedItemsAsRead.scpt) to 10 seconds (instead of 180)

- unload the daemon

sudo launchctl unload /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- replace the plist file with the altered one and reset the permissions

sudo cp /Users/username/com.apple.markdeleteditemsasread.plist /Library/LaunchDaemons/

sudo chown root:wheel /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

sudo chmod o-w /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- load the daemon

sudo launchctl load /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- wait for ten seconds

- verify that the mail is marked read

- don't forget to repeat these steps to set the timer again to 180 seconds!

3 replies
Question marked as Best reply

Jan 13, 2018 3:23 AM in response to jan.claes

I have found out a suitable answer to my own question. Here is what works for me.


1. Make a script to mark all items in trash as read

- Open Script Editor

- Copy next text in the editor

on run {}

tell application "Mail"

set read status of every message of mailbox "Deleted Items" of account "MyAccount" to true

end tell

end run

- Change "Deleted Items" into the name of your trash folder (keep the quotes). If you don't know the exact name, check below under PS1.

- Change "MyAccount" into the name of your account (keep the quotes). If you don't know the exact name, check below under PS2.

- Test by making sure that you have at least one unread mail in Trash, press run in Script Editor and verify that all mails in Trash are now marked read

- Save the file as a script file (extension scpt) in a location where it does not bother you.


2. Make a launch daemon to schedule the execution of the script

- Open Text Editor

- Copy next text in the editor

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.apple.markdeleteditemsasread</string>

<key>ProgramArguments</key>

<array>

<string>osascWooooWript</string>

<string>/Users/username/MarkDeletedItemsAsRead.scpt</string>

</array>

<key>StartInterval</key>

<integer>180</integer>

</dict>

</plist>

- Delete WooooW from the above text (I had to include it to be able to post this here).

- Change the label value (which is currently com.apple.markdeleteditemsasread). If you own a website, it is a good idea to refer to your domain (instead of apple.com).

- Change the script location to where you have saved the script (which is currently /Users/usrename/MarkDeletedItemsAsRead.scpt)

- Change the interval if desired (it is now set to 180 seconds, which is 3 minutes)

- Save the file to a temporary location. Use the label as name (not sure if this is required, but I guess it is a good practice) and plist as extension (in my case the file name will be: com.apple.markdeleteditemsasread.plist ).


3. Activate the launch deamon

- Open Terminal

- Copy the plist file to /Library/LaunchDaemons, for example:

sudo cp /Users/username/com.apple.markdeleteditemsasread.plist /Library/LaunchDaemons/

- Change the permission properties of the file as follows (makes it a file owned by your admin user that cannot be changed by other users):

sudo chown root:wheel /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

sudo chmod o-w /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- Launch the deamon (see PS3 to find out how to test if it works):

sudo launchctl load /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- Optional: Delete the original plist file if it works (I advise to keep it for a while though for testing, see PS3 below)

- Do not delete the plist file in /Library/LaunchDaemons

- Do not delete the scpt file


Good luck!


Jan Claes


PS1 If you don't know the exact name of your trash folder:

- comment the set-intstruction in your script (by preceding the line with two dashes)

- select an email in your trash (in the Mail app)

- put the command "selection" (without quotes) within the tell-block

- press run

- the name is after mailbox

- your script will look like this

on run {}

tell application "Mail"


--set read status of every message of mailbox "Deleted Items" of account "MyAccount" to true


selection

end tell

end run

- and the output will look like this

{messageid 45452 of mailbox "Trash" of accountid "E7533424-41C1-4AC2-66D6-344C0DB8C2AC" of application "Mail"}

PS2 If you don't know your account name:

- go to Mail

- go to settings (Cmd-,)

- go to Accounts

- check name in overview on the left


PS3 How to test your daemon:

- mark at least one file in Trash as unread

- change the time interval in the original plist file (in my case in /Users/username/MarkDeletedItemsAsRead.scpt) to 10 seconds (instead of 180)

- unload the daemon

sudo launchctl unload /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- replace the plist file with the altered one and reset the permissions

sudo cp /Users/username/com.apple.markdeleteditemsasread.plist /Library/LaunchDaemons/

sudo chown root:wheel /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

sudo chmod o-w /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- load the daemon

sudo launchctl load /Library/LaunchDaemons/com.apple.markdeleteditemsasread.plist

- wait for ten seconds

- verify that the mail is marked read

- don't forget to repeat these steps to set the timer again to 180 seconds!

Jan 13, 2018 3:28 AM in response to John Galt

Thanks John.

Actually I was referring to automatically mark all mails in the Trash folder as read (to get rid of the annoying bubble displaying the number of unread messages). I posted the question simply to be able to post the answer here for others to discover, but I got delayed because my reply was blocked (see note about deleting WoooW in my answer) ;-)

Automatically mark messages as read in Trash

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