Extracting embedded inline images CID from MSG file

60 Views Asked by At

I am working on showing previews of MSG files. For this, I am parsing the email content in Java. To read the MSG file, I am using Apache POI (and want to limit my need to add additional dependency). Now, I want to extract the CID of inline embedded attachments. For this I am getting all the attachments from the MAPIMessage object but the CID is not present in the AttachmentChunks as an attribute.

MAPIMessage message = new MAPIMessage(fileInputStream);
AttachmentChunks[] attachments = message.getAttachmentFiles();

However, I can see the CID is present inside AttachmentChunks::getChunks (refer image) array but in no particular order. How can I get the images CID?

CID present in attachment chunk

1

There are 1 best solutions below

0
Eugene Astafiev On

You can read the CID attribute values of each embedded attachment from the message body where images are used. The attribute can be missed on the attachment.