A Mail Archiver user went a bit overboard with testing. Instead of using one small mailbox for testing if the blue coloring works fine she colored all her emails. Ooops! I'll explain what exactly the blue coloring is and how to reverse it. Then I'll apply the script for another property of an email.

What does coloring email backgrounds mean in Mail?

In the below screenshot the first emails have an orange flag. The other emails have a blue background.

Emails with flags and colored backgrounds in Mail

For some reason the background color of an email in Mail can only be set with AppleScript.

Why should you use background coloring in Mail Archiver?

Mail Archiver can delete emails for Mail, Outlook and IMAP. Even though Mail Archiver always checks if an email is in the archive deleting data can be scary. To alleviate that it's possible to give the emails a blue background instead of moving them to the trash:

Coloring and recoloring the background of emails in Mail

The syntax for coloring the background is quite simple according to the AppleScript dictionary of Mail. The third entry for message is about "background color":

So I need a reference to a message and then I have to set the background color to a predefined value. Or I can reset the background color to "none".

I've done getting the selection of Mail many times before so there is nothing really new in the below script. Only the line to set the background color is new:

tell application "Mail"

   
--check if there is an email selected
   
set SelectedMessages to (get selection)
   
if SelectedMessages = {} then
       
display dialog "Please select an email first!"
       
return
   
end if

   
repeat with theMessage in SelectedMessages
       
set background color of theMessage to blue
   
end repeat
end tell

This works fine for a smaller number of emails. The Mail Archiver user had changed the background color of many emails. Selecting emails and then changing the background color of many mailboxes would be really painful.

I know how to get the mailboxes of an account. I also know how to loop over all mailboxes of an account. "messages" of a mailbox can talk to all emails of a mailbox. With this information I can now change the background of all emails of an account:

tell application "Mail"
   
set theMailboxes to mailboxes of account "Mothsoftware-Test"
   
repeat with theMailbox in theMailboxes
       
set background color of messages of theMailbox to none
   
end repeat
end tell

Of course, for your accounts to have to replace "Mothsoftware-Test" with your account name. If you have less than a couple of dozen accounts the script should be fine. Be aware that changing all emails in an account will be super slow. But it's not a script that will run often.

Script variation: setting all emails of an account to read

Mail easily gets confused with counting emails. Sometimes there is an email that is unread that I can't locate. In the AppleScript dictionary I see another property for message with the name of "read status". The property is a boolean and so it can have to values of true and false.

In the above script for resetting the background color I just need to swap the background color with the read status. The following script will set all emails of an account to read:

tell application "Mail"
    
set theMailboxes to mailboxes of account "Mothsoftware-Test"
    
repeat with theMailbox in theMailboxes
        
set read status of messages of theMailbox to true
    
end repeat
end tell