I'm using imaplib for my project because I need to access gmails accounts. Fact: With gmail's labels each message may be on an arbitrary number of folders/boxes/labels.
The problem is that I would like to get every single label from every single message.
The first solution it cames to my mind is to use "All Mail" folder to get all messages and then, for each message, check if that message is in each one of the available folders.
However, I find this solution heavy and I was wondering if there's a better way to do this.
Thanks!
To get all the labels for a given message within gmail you can do the following
t, d = imapconn.uid('FETCH', uid, '(X-GM-LABELS)')
or
t, d = imapconn.fetch(uid, '(X-GM-LABELS)')
BTW: You can find more on gmail imap extensions at http://code.google.com/apis/gmail/imap/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With