Mail got an error: Can't get message id xxx of mailbox "Spam"

On Apple Mail I’m using the SpamSieve script to move messages from my Spam folder to Trash and delete them. And I’m using this with FastScript.

Frequently when I use my move and delete mail shortcut I get this message “Mail got an error: Can’t get message id xxx of mailbox “Spam”” It then asks if I want to edit the script.

Each time the number is different and then I have to go to Trash and manually delete the messages.

Can this be fixed?

Thanks,

Which version of Mac OS X are you using? What is the date at the top of your copy of the Apple Mail - Discard Spam script?

Hi,

Answers to your questions:

1: OS X 10.11.2

2: The top of the script reads as follows:
– Downloaded From: http://c-command.com/scripts/spamsieve/apple-mail-discard-spam
– Last Modified: 2015-10-19

Bob

It looks like you have the newest versions of everything. Please change pEnableDebugLogging in the script from false to true. Then run the script and, if it reports an error, see what log entries Console shows from the script. Also, when running the script from Script Editor, which line does it show that the error occurred at?

Thank you Michael!

Script changed and working perfectly for now. It would work like this about 50% of the time and then do the other thing. I’ll wait to collect more Spam and keep running it then report back to you.

Best wishes,

Bob

Hi Michael,

Spam is consistently emptying into Trash and deleting itself.

Thank you!

b

Update
The amended script is still working flawlessly… thank you

new script error
Hi Michael,

Within the past 2 weeks your script has begun to show -1728 errors again – every so often my shortcut (Command T) moves spam emails from Spam to Trash instead of trashing them. On other occasions the mail is trashed as it should be.

I have both Fastscripts and Apple Scripts running at the same time.

Thanks,

Bob

Please check what I wrote in #4](Mail got an error: Can't get message id xxx of mailbox "Spam" - SpamSieve - C-Command Software Forum).

This line of script is highlighted when I “view script” from the Apple Script Log - so I presume this is the error:
set _messageID to message id of _message

First message:
With 1 message in spam and 2 in trash I ran it from Script Editor and it moved the message from spam to trash without deleting it. Script Editor said this:
error “Mail got an error: Can’t get message id 83175 of mailbox “Spam”.” number -1728 from message id 83175 of mailbox “Spam”
Console said this:
2016-01-29 12:27:45.157 PM robertappleton[1564]: SpamSieve [Discard Spam Script] Moved message to trash: 470428035837547049821476@yllm5ke.adsfotap.top

Scond message:
With 1 message in Spam and 3 in trash I ran it from Script Editor, it moved the message from spam to trash and also deleted it.
Console said this:
2016-01-29 12:38:20.791 PM Script Editor[1542]: *** WARNING: Method selectedRowEnumerator in class NSOutlineView is deprecated. It will be removed in a future release and should no longer be used.
2016-01-29 12:38:20.829 PM robertappleton[1574]: SpamSieve [Discard Spam Script] Found 1 messages in mailbox “Spam”.
2016-01-29 12:38:20.856 PM robertappleton[1575]: SpamSieve [Discard Spam Script] Moved message to trash: 815377808e314124159390ed303d04@WOnaboBrrAAl.r1.TAXeNd.eU
2016-01-29 12:38:20.887 PM robertappleton[1576]: SpamSieve [Discard Spam Script] Deleting message from trash: 815377808e314124159390ed303d04@WOnaboBrrAAl.r1.TAXeNd.eU
2016-01-29 12:38:20.917 PM robertappleton[1577]: SpamSieve [Discard Spam Script] Error deleting message from trash: Can’t make «class meid» of item 3 of {«class mssg» id 83186 of «class mbxp» “Deleted Messages” of application “Mail”, «class mssg» id 83183 of «class mbxp» “Deleted Messages” of application “Mail”, «class mssg» id 83180 of «class mbxp» “Deleted Messages” of application “Mail”, «class mssg» id 83174 of «class mbxp» “Deleted Messages” of application “Mail”, «class mssg» id 83169 of «class mbxp» “Deleted Messages” of application “Mail”} into type Unicode text.
2016-01-29 12:38:20.942 PM robertappleton[1578]: SpamSieve [Discard Spam Script] Mail deleted all the moved messages from the trash
Script Editor Log said this:
end tell
tell current application
do shell script “/usr/bin/logger -s ‘SpamSieve [Discard Spam Script] Mail deleted all the moved messages from the trash’”
–> “”
end tell
Result:
“”

3rd message:
Ran from Script Editor. Moved to trash did not delete.
Console said this:
2016-01-29 12:45:10.627 PM robertappleton[1582]: SpamSieve [Discard Spam Script] Found 2 messages in mailbox “Spam”.
2016-01-29 12:45:10.655 PM robertappleton[1583]: SpamSieve [Discard Spam Script] Moved message to trash: vm35FCD0xxgkUV99esSZ5pYpIK0jUcVL8sFuEUP4cxA.1MvVBXBZ1TxjlxWfKuAWfUZyHx_vb9AS9lNkqWcEb_g@soundtwo.top
Script Editor said this:
error “Mail got an error: Can’t get message id 83184 of mailbox “Spam”.” number -1728 from message id 83184 of mailbox “Spam”
Script Editor Log said this:
tell current application
do shell script “/usr/bin/logger -s ‘SpamSieve [Discard Spam Script] Moved message to trash: vm35FCD0xxgkUV99esSZ5pYpIK0jUcVL8sFuEUP4cxA.1MvVBXBZ1TxjlxWfKuAWfUZyHx_vb9AS9lNkqWcEb_g@soundtwo.top’”
–> “”
end tell
tell application “Mail”
delete message id 83184 of mailbox “Spam”
–> error number -1728 from message id 83184 of mailbox “Spam”
get message id of message id 83184 of mailbox “Spam”
–> error number -1728 from message id 83184 of mailbox “Spam”
Result:
error “Mail got an error: Can’t get message id 83184 of mailbox “Spam”.” number -1728 from message id 83184 of mailbox “Spam”

Thanks for all that information. It looks like the underlying problem is that Mail is reporting an error when trying to delete the message, and again when trying to get information about the message to log the error. I’ll see if there’s at least a way to make it retry or move onto the next message instead of stopping.

So this would not have anything to do with running FastScripts and AppleScript at the same time - I asked this in my previous message – because currently they’re both open in the nav bar at the top of my macbook pro screen.

I don’t think so. That’s a common configuration, and they shouldn’t interfere with each other.

I have updated the script with better error handling.

Thanks - so far so good. Will keep you informed.

After an entire day of work I emptied my spam folder 4 or 5 times, and your new script works flawlessly. Thank you.

116 spam messages deleted this morning - using my shortcut command-T.
And, if necessary, a second execution of command-T removes any remaining or new messages.
Thanks

Michael, This just a follow-up message for anyone else who was having the same problem as me. With Michael’s latest script - the way to ensure spam is sent to trash and trash is emptied automatically, is simply to execute the shortcut for your script twice - for example my shortcut for the older script was shift-command-T. And now I simply execute the shortcut as shift-command-TT. That’s all - and it has worked consistently for over a week now.

b

Running script again to Fix?

I have the exact same issue “can’t get message id …” (error -1728), and have been finding this on different forums. I find running my script again will clean up the remaining messages… however this does not help those that need to run it once for whatever reason… like myself.

Running apple mail v 6.6
OS X 10.8.3

Would love some insight on a real solution.

Thank you

What is the date at the top of your version of the script?