我正在使用 exchangelib 包连接到 Exchange。我需要在回复中发送附件。当我发送普通消息时,我将附件添加到 Message 对象,如下所示:
message = Message()
message.account = account
message.subject = 'subject'
message.body = 'text'
message.to_recipients = [Mailbox(email_address='example@gmail.com')]
message.cc_recipients = ['example2@gmail.com']
for attachment in attachments or []:
with open(attachment['path'], 'rb') as f:
file = FileAttachment(name=attachment['file_name'], content=f.read())
message.attach(file)
并发送回复:
reply = message.reply(
subject='Re: subject',
body='texto',
to_recipients=['example@gmail.com']
)
这可行,但我现在不知道如何在回复中添加附件。我试图设置属性“附件”和“附件”,但对象没有它们。