I am having great time while working with this library.
My requirement is to get mail attachments from sub folder of inbox from mail id.
So far I got to know that from mail id(Message id) we can get that particular mail.
Code I am using for mail id -
Fetching mail from inbox and after moving that to different folder
account.inbox.all().order_by('-datetime_received').reverse() getting mail from inbox - email
email.move(account.inbox / "sub_folder_of_inbox")
email.id We have only this email id - this is some large string
Now mail is moved to sub_folder_of_inbox and we have id of mail too (from above code),
Requirement is to get attachments of that mail.
Code I followed-
sub_folder_mails=sub_folder_of_inbox.filter(message_id__in=['some large string mail id'])
for mail in sub_folder_mails:
print(mail.subject)
And after getting mail I can get attachments
But this code is not giving required result , I am getting sub_folder_mails as QuerySet
To get an item by ID, do this:
Documented in https://ecederstrand.github.io/exchangelib/#searching
Attachments on an item can be accessed via
item.attachment. See https://ecederstrand.github.io/exchangelib/#attachments