2

By using the search query, I am able to get the ids of the all the emails. Now I want to download the attachments from those email. How can I implement that? Any advice would be appreciated, stuck here for a day!

EDIT: This is the search query:

m = imaplib.IMAP4_SSL('imap.gmail.com')
m.login(username, password)
m.select('inbox')
resp, data = m.uid('search', None, 'X-GM-RAW', 'has:attachment filename:xls')
emailids = data[0].split()
Cacheing
  • 3,431
  • 20
  • 46
  • 65

1 Answers1

-1

This has already been answered - in the body of this question:

Get the Gmail attachment filename without downloading it

I just used it myself and it works great - although I would suggest prepending the email from the message to the filename so you have some reference point if you're doing this over lots of emails.

Community
  • 1
  • 1