mercredi 13 juillet 2016

Save email attachment to file in python 2.7


Hi I have a similar question to this: Getting mail attachment to python file object I want to save all files attachments to files on my hard drive from email. But if I am correct not all parts of multipart email are "real" files (for ex. some images in html part of email). I want to be 100% sure that files I save are attachments. for now I have this: mail = ""; for line in sys.stdin: mail += line; msg = email.message_from_string(mail); for part in msg.walk(): check if is file and save

Aucun commentaire:

Enregistrer un commentaire