Ideas how to mass delete emails sent to group

3,478 views
Skip to first unread message

NCE

unread,
Aug 28, 2012, 9:27:29 PM8/28/12
to google-ap...@googlegroups.com
Hello,  We have set up googleapps and email for our school district.  We have already had an issue where a staff member went and mass emailed to a "staff" group when they ment to email to a person whosr name started with "st" and werent paying attention.  Is there a way to retract an email other than logging into hundreds of accounts and trashing the email manually?  Something that could parse the subject lines with the subject line of the missent email and remove it?


I would think this could be useful for many people.  Even if they have to go to the admin to do it, it sure would be nice to have that safety margin.

Thanks,
Dan.

Seb Harrington

unread,
Oct 24, 2012, 6:20:29 AM10/24/12
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us
Seconded!

Jay Lee

unread,
Oct 24, 2012, 9:44:10 AM10/24/12
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us
There is a open source Python script that can delete a mesage with a given message ID from multiple mailboxes:


If anyone gives it a try, report your results back here for the benefit of others!

Regards,

Jay Lee
Large Customer Deployment Lead   |  ⚡ Dito



Seconded!
--
You received this message because you are subscribed to the "Google Apps Manager" group.
To post to this group, send email to
google-ap...@googlegroups.com
To unsubscribe from this group, send email to
google-apps-man...@googlegroups.com
For more options, visit this group at
https://groups.google.com/forum/#!forum/google-apps-manager

Alex Harrington

unread,
Nov 14, 2012, 6:57:04 AM11/14/12
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us
> If anyone gives it a try, report your results back here for the benefit of others!

I had a go with this today.

Firstly it only works for accounts set to a US locale where the place deleted emails go is called "Trash". For a UK setup, you need to modify the code to move items to [Gmail]/Bin

Secondly there's a very nasty bug in there that causes it to delete the wrong message.

Specifically line 282 should read:
unused_type, data = imap_connection.uid('SEARCH', None, search_query)

and line 297 should read:
imap_connection.uid('STORE', num, '+FLAGS', '\\Deleted')

So that we're always using universal identifiers to reference the messages rather than using volatile identifiers.

Thirdly unless you can somehow bulk-adjust the advanced IMAP settings for Gmail, the best the script will do is be able to move emails to the Bin/Trash folder. Gmail's IMAP implementation with default settings does not let you permanently delete emails.

I spent a couple of hours on this this morning - and that's my findings. Very happy to be proven wrong, especially on the last point! But this is a huge improvement on the situation we had before.

If anyone in the UK wants a copy of the script with those two bugfixes and the code updated to look for a "Bin" folder, give me a shout and I'll send it over.

Cheers

Alex
-- 
Alex Harrington
Longhill High School, Network Development Manager

Jay Lee

unread,
Nov 15, 2012, 12:55:00 PM11/15/12
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us
Alex,

  Thanks so much for providing an update on this! I emailed the original developer of the script and he's looking at making some improvements. In the mean time, I had some time to do my own testing. I was able to get the script to fully purge the messages with a few changes in addition to yours. The script is attached. Note that you must run with the --purge parameter and it's possible my changes broke the move to label or copy to label functionality, I only tested full purge.







Regards,

Jay Lee
Large Customer Deployment Lead   |  ⚡ Dito



--
imap_email_mover.py

Jay Lee

unread,
Nov 15, 2012, 1:14:15 PM11/15/12
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us
Actually, one more update. I stole some of my code from GYB to auto-detect local-specific names for Trash, All Mail and Spam. That should save the need to change the code to read Bin instead of Trash.


Regards,

Jay Lee
Large Customer Deployment Lead   |  ⚡ Dito



imap_email_mover.py

Alex Harrington (Staff)

unread,
Nov 16, 2012, 4:04:19 AM11/16/12
to google-ap...@googlegroups.com
Hi Jay

Thanks for your changes. The folder name detection works fine, however even with --purge=yes set the item is still in my Bin folder at the end of the run.

From the IMAP settings:

When a message is marked as deleted and expunged from the last visible IMAP folder:

So I don't think it will be possible with default settings to purge the message? Or did I miss something?

Thanks

Alex

-- 
Alex Harrington
Network Development Manager
Longhill High School
t: 01273 304086 | e: al...@longhill.org.uk

Alex Harrington (Staff)

unread,
Nov 16, 2012, 4:10:12 AM11/16/12
to google-ap...@googlegroups.com
.. although having just checked with some of my colleagues it was purged correctly for them.

It also created a [Gmail]/Trash folder in our mailboxes so it looks like there's at least one place where it's still looking at the wrong value.

Cheers

Alex
-- 
Alex Harrington
Network Development Manager
Longhill High School
t: 01273 304086 | e: al...@longhill.org.uk



Alex Harrington (Staff)

unread,
Nov 16, 2012, 4:20:53 AM11/16/12
to google-ap...@googlegroups.com
Yes it's line 284 that's creating the folder. It would be lovely to get that fixed as well :)

On the not purging thing, I think it's possibly because I sent the email in question that it wasn't fully purged. Testing with an email sent to me it was deleted from the Bin correctly as well.

Many thanks - that's the last "thing I can't do with Gmail that I could with Exchange" ticked off!

Alex

-- 
Alex Harrington
Network Development Manager
Longhill High School
t: 01273 304086 | e: al...@longhill.org.uk



Justin Buchanan

unread,
Mar 3, 2015, 11:04:54 AM3/3/15
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us, j...@ditoweb.com, al...@longhill.org.uk
Does anyone know if imap_email_mover.py is still working?
I just tried to use it an OAUTH seems to be failing. 

Thank you 

Please be advised that the Attorney General has ruled that communication via electronic mail in the public domain is not confidential and is considered a matter of public record. Furthermore, all communications (including this one) will be retained for 10 years.

Brandon U.

unread,
Mar 3, 2015, 11:10:57 AM3/3/15
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us
There is a "Got Your Back" application I believe Jay created that would allow you to do this. Best thing to do once you get it setup is to search and delete based on Message ID

Jay Lee

unread,
Mar 3, 2015, 11:11:17 AM3/3/15
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us, Jay Lee, al...@longhill.org.uk
You could try using GYB and the instructions at:


there's also a project at:


that can delete messages. Setup is more involved but once setup it's all web interface.

Jay Lee

--
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/7ecf0203-6a3c-49b9-909c-91b3590426bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Buchanan

unread,
Mar 3, 2015, 11:15:22 AM3/3/15
to google-ap...@googlegroups.com, googl...@nce.k12.mn.us, j...@ditoweb.com, al...@longhill.org.uk
That is fantastic.  Thank you Jay. I am going to set this up now. 
Thank you again for your help and your quick response. 


On Tuesday, March 3, 2015 at 11:11:17 AM UTC-5, Jay Lee wrote:
You could try using GYB and the instructions at:


there's also a project at:


that can delete messages. Setup is more involved but once setup it's all web interface.

Jay Lee

On Tue, Mar 3, 2015 at 11:03 AM, Justin Buchanan <buch...@suttonschools.net> wrote:
Does anyone know if imap_email_mover.py is still working?
I just tried to use it an OAUTH seems to be failing. 

Thank you 

On Tuesday, August 28, 2012 at 9:27:29 PM UTC-4, NCE wrote:
Hello,  We have set up googleapps and email for our school district.  We have already had an issue where a staff member went and mass emailed to a "staff" group when they ment to email to a person whosr name started with "st" and werent paying attention.  Is there a way to retract an email other than logging into hundreds of accounts and trashing the email manually?  Something that could parse the subject lines with the subject line of the missent email and remove it?


I would think this could be useful for many people.  Even if they have to go to the admin to do it, it sure would be nice to have that safety margin.

Thanks,
Dan.

Please be advised that the Attorney General has ruled that communication via electronic mail in the public domain is not confidential and is considered a matter of public record. Furthermore, all communications (including this one) will be retained for 10 years.

--
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.
Reply all
Reply to author
Forward
0 new messages