0

I've been getting a lot of spam emails from various colleges. I wrote a simple Python program to go through my emails, and find all the ones whose sender ends in .edu.

Then, to delete it, I though I was supposed to add the \\Deleted flag to those emails using: Gmail.store(id, "+FLAGS", "\\Deleted"). This did not work, and some of them didn't even disappear from the inbox.

After more research, I found that instead I had to use Gmail.store(id, "+X-GM-LABELS", "\\Trash").

So I updated the program to use that, but now it doesn't see any of the emails that I previously added the \\Deleted flag to.

Is there any way I can reset all those emails and then trash them afterward?

Caleb H.
  • 1,657
  • 1
  • 10
  • 31
  • 1
    They should be in your All Mail folder. Use the webui and search for them and trash them. – Max Apr 05 '19 at 22:00
  • Oh, I see...what do I `Gmail.select` to get the "All Mail"? – Caleb H. Apr 05 '19 at 22:18
  • In my python code – Caleb H. Apr 05 '19 at 22:18
  • If it's a one off, why use Python? Its locale specific, but in English it should be something like "[Gmail]/All Mail" – Max Apr 05 '19 at 22:28
  • I'm using Python because there's 700 or so of them. – Caleb H. Apr 05 '19 at 22:31
  • Thanks for the input. I tried that, but it gives me `SELECT command error: BAD [b'Could not parse command']` – Caleb H. Apr 05 '19 at 22:36
  • I'm also using Python because I'm going to probably keep receiving them for a while (I haven't unsubscribed from all of them yet), so I'll use it again another time. – Caleb H. Apr 05 '19 at 22:49
  • Ok, the problem was addressed in this SO post: https://stackoverflow.com/questions/25186394/unable-to-retrieve-gmail-messages-from-any-folder-other-than-inbox-python3-issu – Caleb H. Apr 05 '19 at 22:51
  • If you want to make an answer, I'll mark it as correct. – Caleb H. Apr 05 '19 at 22:52
  • I meant, why use a script for the one off clean-up, now that you know how to do it. I've made an answer for you. – Max Apr 05 '19 at 23:49
  • Not sure if I understand, but I wanted to make sure I deleted those emails because I wanted to free up space on Gmail. A lot of them had image attachments and HTML. – Caleb H. Apr 06 '19 at 00:29
  • Ah, what I meant i that future ones will be in your inbox, and you know how to deal with them properly. Cleaning up the ones in your All Mail from your previous script is only something you need to do once. – Max Apr 06 '19 at 00:43
  • Oh. Well again, since there was 700 of them, it would have taken me a while. – Caleb H. Apr 06 '19 at 12:50

1 Answers1

1

They should be in your All Mail folder. Use the WebUI and search for them and trash them, or select the "[Gmail]\All Mail" folder (watch out for localization, this can change name for non-English users).

Max
  • 10,701
  • 2
  • 24
  • 48