I want to get emails’ attachments drom Office 365, but doent go to the second loop (it seems that there are not attachments, but that is not true). Any idea?
authO365 = (str(usermail),str(passmail))
i = Inbox(authO365,getNow=False)
i.setFilter("IsRead eq false")
i.getMessages()
for email in i.messages:
#print(i.messages)
subject = email.getSubject()
print(subject)
body = email.getBody()
mailsender = email.getSenderEmail()
atta=email.attachments
print(atta)
for attachment in atta: #this loop
report_name = date_time + '_' + attachment.FileName
attachment.SaveASFile(my_path + '/' + report_name)
print('Attachment saved: ' + report_name)