-----
- Implement attachments support. It's now possible to create, delete and get attachments connected to any item type:
python
from exchangelib.folders import FileAttachment, ItemAttachment
Process attachments on existing items
for item in my_folder.all():
for attachment in item.attachments:
local_path = os.path.join("/tmp", attachment.name)
with open(local_path, "wb") as f:
f.write(attachment.content)
print("Saved attachment to", local_path)
Create a new item with an attachment
item = Message(...)
binary_file_content = "Hello from unicode æøå".encode(
"utf-8"
) Or read from file, BytesIO etc.
my_file = FileAttachment(name="my_file.txt", content=binary_file_content)
item.attach(my_file)
my_calendar_item = CalendarItem(...)
my_appointment = ItemAttachment(name="my_appointment", item=my_calendar_item)
item.attach(my_appointment)
item.save()
Add an attachment on an existing item
my_other_file = FileAttachment(name="my_other_file.txt", content=binary_file_content)
item.attach(my_other_file)
Remove the attachment again
item.detach(my_file)
Be aware that adding and deleting attachments from items that are already created in Exchange (items that have
an `item_id`) will update the `changekey` of the item.
- Implement `Item.headers` which contains custom Internet message headers. Primarily useful for `Message` objects.
Read-only for now.