Using GAM to delete erroneously sent emails

Sometimes someone sends an email and wants to unsend it. It doesn’t happen very often, and usually there isn’t much you can do about if the email has been sent to an external recipient. If your organization uses G-Suite, though, you can delete internally sent emails. Just be careful. And also know that it’s still possible that the recipient may see the deleted message anyway.

First, install GAM or Advanced GAM if you haven’t already.

Then you can search for the message:

gam user delete messages query ‘subject:”Totallyatestmessage”‘
Searching messages for
Got 1 messages for user
would try to delete 1 messages for user (max 1)
Once you’re confident that’s the message you want, append doit to the command to actually delete the message:

gam user delete messages query ‘subject:”Totallyatestmessage”‘ doit
Searching messages for
Got 1 messages for user
delete 1 messages
delete 1 of 1 messages

This won’t move the message to the trash. It will straight up delete it. (There are options to just trash a message, though.)

Based on some testing I did, if you have Gmail set up in an external email program, the preview of the message may still be there, even after the message is deleted.

Once you delete it, the cached message will remain in the external email program for a while. If you tap on the cached message, you see the body of the message for a split second, and then the whole message disappears.

P.S. A previous version of this didn’t have single quotes around the subject. Kudos to Stace Felder for doing testing on this and finding that without the single quotes, GAM won’t look for a subject with that exact string—only subjects that have all the words.

3 responses to “Using GAM to delete erroneously sent emails”

  1. Very helpful article. I found out that you can use the following command to add multiple querys, for example (from/subject) and, at least on Windows, apostrophe and quote locations will make a difference.

    gam user delete messages query “ subject:’Email Subject’” doit

Leave a Reply

Your email address will not be published. Required fields are marked *

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