imap_tools - Download attachments in python

Viewed 1354

i would like to download the attachments of a couple of emails. I got to store the attachment names in an list, but i don't really know what to do now. I want to download them and work with this files(xlsx) afterwards. The names are stored in the list "atts". This is the code it got so far:

mailbox.login(imap_user, imap_pass, initial_folder='INBOX')

y = 1

# Erstellung einer Liste, um die Namen der Anhänge zu speicern und auslesen zu können. 
atts = []

for msg in mailbox.fetch('unseen', mark_seen=False):
    for i in msg.attachments:
        print(str(y) + ": " + i.filename)
        y+=1
        atts.append(i.filename)```
1 Answers
Related