Script to remove messages from users' inbox.

995 views
Skip to first unread message

John Reiels

unread,
Jul 1, 2014, 7:13:12 AM7/1/14
to google-ap...@googlegroups.com
Two email messages were inadvertently sent to our entire domain (high school students) and the message was intended only for staff.  I would like to remove the messages from the inboxes of students (or all users if need be).  I am new to GAM, but was referred here by a support provider.  Is someone able to help me with a script I can run in GAM so that I can remove the specific messages from the users' inboxes?

Thanks!

Jay Lee

unread,
Jul 1, 2014, 8:14:51 AM7/1/14
to google-ap...@googlegroups.com
GAM can't do this but GYB, another open source tool I maintain, can. It just so happens a good article on how to do this was written just yesterday:



Jay Lee


On Tue, Jul 1, 2014 at 7:13 AM, John Reiels <john....@nicolet.us> wrote:
Two email messages were inadvertently sent to our entire domain (high school students) and the message was intended only for staff.  I would like to remove the messages from the inboxes of students (or all users if need be).  I am new to GAM, but was referred here by a support provider.  Is someone able to help me with a script I can run in GAM so that I can remove the specific messages from the users' inboxes?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/45926c66-c92b-4e09-ba0e-03ed2eacbc72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brandon U.

unread,
Jul 1, 2014, 9:18:43 AM7/1/14
to google-ap...@googlegroups.com
Can I use the same client_secrets.json from gam with gyb?

Jay Lee

unread,
Jul 1, 2014, 9:20:31 AM7/1/14
to google-ap...@googlegroups.com
I'd recommend making a new one (it's not like they cost anything)


Jay Lee


On Tue, Jul 1, 2014 at 9:18 AM, Brandon U. <bushe...@gmail.com> wrote:
Can I use the same client_secrets.json from gam with gyb?

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-apps-manager.

Brandon

unread,
Jul 1, 2014, 9:21:01 AM7/1/14
to google-ap...@googlegroups.com

John Reiels

unread,
Jul 1, 2014, 12:27:23 PM7/1/14
to google-ap...@googlegroups.com
Thanks for the help.  Sorry for the rookie questions.  I have got everything ready to enter the script to search for, and purge the message.  Where do I enter the script to get it to run?  I have lots of accounts from which to delete the message and would like to use a Google sheet to set this up, per your instructions.  Do I need to reference the sheet/file ID so the script knows where to pull it from or how do I get the script that's looking for column A and B data, to see the file where the data is located?

Thanks again.


On Tuesday, July 1, 2014 8:14:51 AM UTC-4, Jay Lee wrote:
GAM can't do this but GYB, another open source tool I maintain, can. It just so happens a good article on how to do this was written just yesterday:



Jay Lee


On Tue, Jul 1, 2014 at 7:13 AM, John Reiels <john....@nicolet.us> wrote:
Two email messages were inadvertently sent to our entire domain (high school students) and the message was intended only for staff.  I would like to remove the messages from the inboxes of students (or all users if need be).  I am new to GAM, but was referred here by a support provider.  Is someone able to help me with a script I can run in GAM so that I can remove the specific messages from the users' inboxes?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Brandon U.

unread,
Jul 1, 2014, 7:46:07 PM7/1/14
to google-ap...@googlegroups.com
I assume your best bet would be to make a powershell script that loads a CSV of email addresses such as below:

#Change these variables to what you have in your environment

#Location of csv with header of "email" and listing the email accounts that received the email
$file
= "C:\EmailsWithUnwantedEmail.csv"

#service account email address from google developer console
$serviceAccountEmail
= "12345...@developer.gserviceaccount.com"

#Message ID of unwanted email
$messageID
= "1234567890@localhost"
$searchParam
= "rfc822msgid:" + $messageID

#Action to take on the email. Can either be estimate, purge, count, purge-labels
$action
= "estimate"

$importedCSV
= Import-Csv $file

foreach ($entry in $importedCSV) {
    C
:\path\to\gyb.exe --service-account "$serviceAccountEmail" --search "$searchParam" --action $action --email "$($entry.email)"
}



Francisco Morfin

unread,
Jun 4, 2016, 4:12:33 PM6/4/16
to Google Apps Manager
Perhaps this post is a bit too late but you can also use this toolbox mygapps.tools. In case anybody else find this discussion I hope it is helpful.
Reply all
Reply to author
Forward
0 new messages