0

We have a python script that replies to incoming emails using exchangelib. User A sends us an email that can contain a picture/graphic (e.g. company logo in signature line). Our script is able to reply to his mail, and user A will get our reply. Unfortunately, the picture/graphic that was embedded in the original mail to us, is now an attached file instead of an embedded picture. Here is the code that we're using:

origmsg.reply(
      subject='Re: ' + origmsg.subject,
      body="This is my reply to your inquiry...."
    )

I understand that for new messages the HTML code needs to include a reference to the attached file to make it embedded. How can this be done in a reply? Thanks.

simon
  • 11
  • 1

1 Answers1

0

https://ecederstrand.github.io/exchangelib/#attachments has some example of embedding images in emails.

The .reply() method is for simple replies. You may need to call .create_reply() instead and edit the returned ReplyToItem object as needed before calling .send() on it.

If you have even more special requirements, you can call .save() on the ReplyToItem object to save it as a draft, fetch the draft as a plain Message object with account.drafts.get(id=reply_to_item_id) and do whatever you need to do before sending the draft.

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63