0

After reading this question I ran the script:

How can I download all emails with attachments from Gmail?.

For some reason, not all my labels or messages with attachments are downloading. I think it's either there is a problem with identifying the labels or that I have seven gmail accounts that I sent out. For example my main one is example1@gmail.com but I can send mail as example_2@gmail.com from example1@gmail.com

I did find gmailbackup (another python module) and have it running currently. The problem is that it doesn't download attachments that I've been able to find in the documentation and in the program. I am trying to jerry rig these two source codes together, but I am having problems in reading and understanding the script of gmailbackup.

Community
  • 1
  • 1
user2723240
  • 803
  • 1
  • 13
  • 23

1 Answers1

0

So the problem was with the m.select() function. The m.list() function does not make a list for you to query for each label.

So I added these lines:

   m.list()

   inboxes = list(m.list())

   for item in inboxes[1]:
       mailbox = item.split('"')[3]
       m.select(mailbox) # here you a can choose a mail box like INBOX instead

There are probably better and more efficient ways of doing this, however I was in a hurry. Using re and matches module would probably be great to build in.

Edit: There is a second way of applying a filter that adds the label attached to anything attached and downloading from that label.

Edit 2

Gmail has a limit to downloads per day, so if you are dealing with large emails you might want to track what you have already downloaded.

user2723240
  • 803
  • 1
  • 13
  • 23