Embedding images from Confluence pages in emails

Hello!

I’m developing a Confluence Server java plugin, which will allow users to send stubs of Pages and Blogposts via e-mail messages. I’m missing one final part - how to embed images (hosted in Confluence as attachments) in e-mail messages?

I’m generating html message content this way:

AbstractPage page = pageManager.getAbstractPage(pageId);
DeviceTypeAwareRenderer renderer = (DeviceTypeAwareRenderer)ContainerManager.getComponent("viewRenderer");
ConversionContext conversionContext = new DefaultConversionContext(page.toPageContext());
String pageHtmlContent = renderer.render(page.getEntity(), conversionContext);

In this html code I have img src pointing to attachments, to which access is restricted and no email clients displays those images properly:

Do you have any ideas how to solve this problem? Any help will be much appreciated!

The problem here is ensuring that you have access to the images. Hotlinking is linkely a complete no go.

One way would be for your add-on to grab the image content and base64 encode it then add it inline.

Yeah, I was thinking about adding them inline, but rather as a last resort. I’ll give it a try if no other options come out. Thanks!