sepdek October 22, 2014
mac mail logo

Since the Yosemite update a few days back, I decided to give Mac Mail another chance.

One really annoying thing that I had to face right from the beginning was the lack of a keyboard shortcut for a “must” option to “Erase Deleted Items” “In All Accounts…” (quoting the menu options). There is an incredibly convenient cmd+shft-bkspc shortcut for erasing the deleted items in the selected mailbox, but this option is grayed-out (disabled) for me, probably because I have to deal with multiple email accounts of various types (IMAP, POP, etc).

applescriptSince I already had FastScripts installed I decided to write a small AppleScript and assign it a new shortcut to do the job. To my surprise, even though the code is really simple, I could not succeed! After numerous tests I found out it had to do with the menu item name having that “…” three dots! I tested it again and found out this is true although I could not locate any apple forum or any independent forum and blog entry to mention this…

On the positive side, there is a solution, or better, a workaround: instead of just using the complete menu item string name, there is the possibility to use just part of it. Here is the code that finally did the job for me:

tell application "System Events"
	tell application "Mail" to activate
	delay 0.5
	tell process "Mail" to click (menu item 1 where its name starts with "In All") in menu "Erase Deleted Items" of menu item "Erase Deleted Items" of menu "mailbox" of menu bar 1
end tell

As one may see in this simple piece of code, the key is to use that

(menu item 1 where its name starts with "In All")

part, which ensures that the correct menu item is selected and that the evil “…” is left aside. The rest is just typical AppleScript coding found in similar cases. It may probably be implemented even better but this solution works fine for me.

Final step was to assign a keyboard shortcut (I used cntr+opt+cmd+bkscp) for this script in the FastScripts interface and now I can use this shortcut even when Mac Mail is in the background.



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.