A long long time ago Outlook was a bit finicky. There was an internal database that was prone to corruption. Since 2016 Microsoft got their act together with Outlook and I haven't had any report about corruption since then.

In contrast Mail get's worse with each version.

I have had - now and then - reports about mails not being moved to the trash for Mail. I fiddled with the AppleScript that does the moving. In the script I replaced

set mailbox of theMessage to mailbox 'Trash' of theAccount

with

move theMessage to trash mailbox

The I used both when the first try failed. I added a check if the mail was really moved to the trash.

NO version works 100%. The reason for the failure seem to be problems in Mail.

  • The number of mails for a mailbox seem to be wrong. I have a screenshot where a customer moves 4 (four!) mails to the trash. He is asked if he really wants to move 2,100 mails to the trash.
  • Even checking if the mails were moved to the trash fails. I usually test with a smaller mailbox. Mail Archiver reports that the mails weren't moved to the trash. But I could see that in Mail the mailbox was empty.

Possible solution 1: rebuild a mailbox

In Mail you can do a rebuild of a mailbox when you select Rebuild from the Mailbox menu. The command has some problems:

  • I can't do the rebuild directly from AppleScript. There is a workaround which leads to other problems.
  • Even if I could do the rebuild from AppleScript I don't know when the command is finished. Then I don't know when I can do the next command.
  • For small mailboxes the rebuild is fast. For larger mailboxes it may take some time. At first it looks like the mails vanish.

As a solution it works for a single mailbox.

Possible solution 2: vacuum the database

Mail uses CoreData which uses encrypted SQLite databases as storage. Therefore, you can use SQLite commands.

  1. Quit Mail.
  2. Give the Terminal app full access to the harddisk in Security and Privacy.
  3. Open Terminal and enter "sqlite3 ~/Library/Mail/V5/MailData/Envelope\ Index vacuum" . On Mojave this is V6 instead of V5. Also on Mojave I needed to use "sudo " in front of the command to get the password.
  4. Restart Mail.

(More information is available at https://www.imore.com/how-speed-mail-your-mac-using-automator).

The instructions are abbreviated because as with the rebuild command Apple doesn't really like anyone to much around in the mud. In solution 1 I can't control the sequence. Solution 2 would make more problems with permission settings on Mojave.

So both solutions aren't viable for using in Mail Archiver. However, when you have problems in Mail both work fine.