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 recipient@school.edu delete messages query ‘subject:”Totallyatestmessage”‘
Searching messages for recipient@school.edu
Got 1 messages for user recipient@school.edu
would try to delete 1 messages for user recipient@school.edu (max 1)

Once you’re confident that’s the message you want, append doit to the command to actually delete the message:

gam user recipient@school.edu delete messages query ‘subject:”Totallyatestmessage”‘ doit
Searching messages for recipient@school.edu
Got 1 messages for user recipient@school.edu
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.


Posted

in

by

Tags:

Comments

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

  1. […] Using GAM to delete erroneously sent emails – Alan Siu […]

  2. gam-guy Avatar
    gam-guy

    add: maxtomodify 200000 at the end if you get the max 1 error

Leave a Reply

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