4

I have a script which exports all the email in Gmail as text files.

It works fine with this line where you select the folder:

mail.select("inbox")

But I am not sure what the name is for Gmail's archive, where all of the email is stored. I've tried archive and all mail and stuff, but no luck.

Anyone know the correct name?

samiles
  • 3,768
  • 12
  • 44
  • 71
  • Can you interrogate the IMAP server to ask what folders ARE available? And does Google provide any documentation for their IMAP service? Alternately, if you connect to Gmail using a mail client, does archived mail show up in a folder at all? – Li-aung Yip May 13 '12 at 10:06
  • @Li-aungYip - you can with the list() method. http://docs.python.org/3.1/library/imaplib.html#imaplib.IMAP4.list – d0ugal Feb 13 '13 at 21:04

2 Answers2

11

Solved it.

It is [Gmail]/All Mail or, if you are a Gmail UK user like me, it may be [Google Mail]/All Mail, because Gmail used to be called Google Mail in the UK due to trademark issues.

If you're doing this for general use, I'd recommend testing to see if [Gmail]/All Mail works (most common), and if not testing for [Google Mail]/All Mail.

The last one works perfectly for me.

samiles
  • 3,768
  • 12
  • 44
  • 71
0

This:

https://github.com/goerz/gmail_archive.py/blob/master/libgmail/lgconstants.py

Seems to indicate that it's all.

ubik
  • 4,440
  • 2
  • 23
  • 29