Is there a Keystroke for Complete Deletion of E-mails in the Spam Folder?

It looks like there’s a problem where sometimes Mail reports that the message has moved to the trash before it actually gets there. In that case, the script will not be able to find it in the trash to delete it. I have updated the script so that it will report when this happens and also retry.

I’ve installed the new script (Oct 23, 2014, 14:40) and would report back here if I detect that it doesn’t appear to me to be working that way.

Thanks–especially for the very prompt action as that script’s function is a big help to my workflow.

David

Update: Behavior continued properly through the rest of yesterday; no error alerts thrown and all the messages in the Spam folder were directly deleted each time the script was executed.

Launched Mail (with SpamSieve automatically launching, too) for the first time today about 50 minutes ago and a large number of messages were put into the Spam folder. (Sorry, but I didn’t note the number.)

I then executed the script and it threw up an error dialogue (whose contents I didn’t catch before I lost it; sorry about that) but I found the following in the Console’s “All messages”:
10/24/14 12:58:58.011 dgk[10914]: SpamSieve [Discard Spam Script] Error deleting message from trash: Mail got an error: Can’t get message id 298658 of mailbox “Deleted Messages”.
10/24/14 12:58:58.022 dgk[10915]: SpamSieve [Discard Spam Script] Mail did not delete the messages: E1XhTZq-0002E8-So@host.360space.net
10/24/14 12:58:58.073 dgk[10916]: SpamSieve [Discard Spam Script] Error deleting message from trash: Mail got an error: Can’t get message id 298688 of mailbox “Deleted Messages”.
[Note: I don’t know if it were necessary for those entries, but I had turned on the more verbose logging many months ago as you had suggested earlier in this thread.]

In the SpamSieve Log, I found that it predicted 12 e-mails as Spam.

When I checked my Spam folder and my Trash folder, they were both empty.

Should I conclude the new script, therefore, is doing just what you wanted? Perhaps in this instance, reporting it found one of the group of messages in the Spam folder hadn’t made it to the Trash in time to be dealt with, but it automatically re-ran itself and then was able to deal properly with at least that one message–if not also any remaining messages that might have been awaiting processing after the identified slow-to-Trash message. (From watching the badged number of unread messages in the Spam folder counting down after I execute the script, it seems the script is looping to deal with each message, in turn.)

Since then, I’ve executed the script once more and it performed properly with no error dialogue having been thrown.

Unless you wish any further updating on the behavior of the new script, I won’t report further on it unless the end result of each execution isn’t an empty Spam folder with all of its contents having been directly deleted.

David

The Apple Mail - Discard Spam script will always log errors like this, no changes necessary.

That’s right. If retrying didn’t delete the message it would have reported that.

Thanks; I much appreciate you having “instantly” provided the updated script so the convenience that functionality provides us now is even more robust.

David

Michael,

Over the last couple of days, and most recently a few minutes ago, I have had instances–but far from every time–that when I invoke that script, Mail hangs with the spinning-ball cursor if over a Mail window and my only relief is to do a Force Quit. Note: When that happened, no alert dialogues were thrown by the script–such as it is doing when it didn’t find the e-mail available for deletion and which, you’ve explained, an alert is thrown, but the script retries (and I had always found had been successful on the re-try).

Here are some Console entries that may tell you something. (Note: I’m pretty sure that last entry was after Mail had already hung.)

11/17/14 12:33:33.624 dgk[81605]: SpamSieve [Discard Spam Script] Error deleting message from trash: Mail got an error: Can’t get message id 301256 of mailbox “Deleted Messages”.
11/17/14 12:33:33.635 Mail[54918]: *** Assertion failure in -[MCSocket connectToHost:withPort:isBackground:], /SourceCache/Mail/Mail-1990.1/MailCore/Networking/MCSocket.m:202
11/17/14 12:33:33.638 Mail[54918]: An exception was thrown during execution of an NSScriptCommand…
11/17/14 12:33:33.638 Mail[54918]: This method must be called off the main thread
11/17/14 12:33:33.642 dgk[81606]: SpamSieve [Discard Spam Script] Error deleting message from trash: Mail got an error: AppleEvent handler failed.
11/17/14 12:33:33.655 Mail[54918]: *** -[NSCondition lock]: deadlock (<NSCondition: 0x60800011d7f0> ‘(null)’)
11/17/14 12:33:33.655 Mail[54918]: *** Break on _NSLockError() to debug.
11/17/14 12:34:00.177 Console[81685]: Failed to connect (_consoleX) outlet from (NSApplication) to (ConsoleX): missing setter or instance variable
11/17/14 12:35:01.745 Office365Service[81881]: WARNING: The Gestalt selector gestaltSystemVersion is returning 10.9.0 instead of 10.10.0. Use NSProcessInfo’s operatingSystemVersion property to get correct system version number.
Call location:
11/17/14 12:35:01.745 Office365Service[81881]: 0 CarbonCore 0x9484e7e7 ___Gestalt_SystemVersion_block_invoke + 135
11/17/14 12:35:01.745 Office365Service[81881]: 1 libdispatch.dylib 0x985ad130 _dispatch_client_callout + 50
11/17/14 12:35:01.745 Office365Service[81881]: 2 libdispatch.dylib 0x985ad0b5 dispatch_once_f + 251
11/17/14 12:35:01.745 Office365Service[81881]: 3 libdispatch.dylib 0x985ae0d8 dispatch_once + 31
11/17/14 12:35:01.745 Office365Service[81881]: 4 CarbonCore 0x947e0fb8 _Gestalt_SystemVersion + 1050
11/17/14 12:35:01.745 Office365Service[81881]: 5 CarbonCore 0x947e0b69 Gestalt + 150
11/17/14 12:35:01.745 Office365Service[81881]: 6 Office365Service 0x00058977 Office365Service + 358775
11/17/14 12:35:33.634 dgk[81980]: SpamSieve [Discard Spam Script] Error deleting message from trash: Mail got an error: AppleEvent timed out.

I also have the crash report on Mail which I could provide–perhaps separately because of its length (unless you tell me how much of it you’d want posted her)–if desired. If there’s anything else you need in regards to this problem, just let me know that, too.

Thanks,
David

Unfortunately, it looks like these errors indicate a bug in Mail, so it’s probably something that would need to be fixed by Apple rather than in the script.

OK, Michael. I’ll keep submitting the crash reports to Apple via the automated option that is offered each time I have Force Quit Mail.

Thanks,
David