Displaying Inline Outlook Attachments in Mendix RichText Editor
0
Hello everyone, I am currently working on a project involving integration with the Outlook Graph API, from which I retrieve messages. Occasionally, these messages contain inline images within the message content. The Graph API represents such images as <img> tags with src="cid:...", where the cid corresponds to the ContentId of an attached image. Each image is also returned as an attachment to the email, with its ContentId matching the placeholder in the message body. My goal is to correctly display these inline images within a RichText Editor in Mendix. To achieve this, I’ve implemented logic that loops through all attachments, checks their ContentId, and if a match is found in the message body, replaces the src="cid:..." with a base64-encoded data of the attachment. This approach works, but when emails contain multiple images, the resulting HTML becomes significantly bloated, leading to performance issues and excessive load times. To address this, I explored the possibility of using the path to the downloaded attachments instead of embedding them directly. However, I’ve been unable to determine where Mendix stores these downloaded attachments or how to reference them via a file path in the src attribute. Could you please advise if there is a way to access the stored images directly and reference them by path? Alternatively, is there a more efficient approach to displaying such inline images in the RichText Editor? (If possible I would prefer to stay with RichText Editor, because I found that CKEditor 5 when set to read only mode crashes my Email page) Thanks for the help in advance and I wish you a plesant day!
asked
Paweł Żurawski
1 answers
0
Hi Pawel, Mendix exposes file entities (including images) using the /file endpoint. You can access a specific image using the following URL format: {APP URL}/file?guid={OBJECT GUID}
Since you are looping through the images anyway all you have to do is get the GUID of your Image object. This can be done through the getGUID java action from Community Commons or the getGUID javascript action from NanoflowCommons. See the image below for a working example in the RichText Editor.