I'm using the exchangelib package to connect to Exchange. I need to send attachments in a reply. When I send a normal message I add the attachment to the Message object like this:
message = Message()
message.account = account
message.subject = 'subject'
message.body = 'text'
message.to_recipients = [Mailbox(email_address='[email protected]')]
message.cc_recipients = ['[email protected]']
for attachment in attachments or []:
with open(attachment['path'], 'rb') as f:
file = FileAttachment(name=attachment['file_name'], content=f.read())
message.attach(file)
and to send a reply:
reply = message.reply(
subject='Re: subject',
body='texto',
to_recipients=['[email protected]']
)
This works, but I don't now how to add attachments to the reply. I tried to set the attributes "attachments" and "attach" but the object doesn't have them.