Free Support Forum - aspose.com

Extracted (Attachments or embedded images) documents from EML or MSG files shows increase in file size (Java)

We are using Aspose for extracting attachments from EML & MSG files.
The attachments/embedded images size is not the same as the raw file. After extraction a file is created and this file size not match or a bit more compare to the original file size.

@hassan.khan,

I have observed the issue shared by you and request you to please share the source file along with used sample code along with information which information the API failed to extract on your end.

Below is the code snippet we used:

        MailMessage msg = MailMessage.load(filePath.toString());

        for (int i = 0; i < msg.getAttachments().size(); i++) {
			Attachment attachment = msg.getAttachments().get_Item(i);
            // The above attachment is a file, the size of this file after extraction is not same as the one attached to the parent EML or MSG file.
		}
		
		for (int i = 0; i < msg.getLinkedResources().size(); i++) {
            LinkedResource linkedResource = msg.getLinkedResources().get_Item(i);
             // The above linkedResource  is a file, the size of this file after extraction is not same as the one attached to the parent EML or MSG file.
        }

EML or MSG files will have some attachments, embedded attachments, once after the extraction these attachments will be save as a file. The file size is increased compare to the file size of a file which is attached.

Note: The target file to be tested is an EML file inside the zip file, i was not able to upload EML file so i zipped the EML file and uploaded the zip file.

aspose_bug_filesize.zip (32.3 KB)

@hassan.khan,

After processing your files and extracting attachments, I have been able to observe the issue and a ticket with ID EMAILJAVA-34710 has been created to investigate and resolve the issue. We will notify you once issue will be fixed.

@hassan.khan,

We have proceeded further with investigation. The Linked resource image file extracted from Aspsoe.Email is equal to RAW file added in source EML. The file saved from Outlook is not equal to source.

We can check it for "image001.png"

“image001.png” source

Content-Type: image/png;
name=“image001.png”
Content-Transfer-Encoding: base64
Content-ID: image001.png@01D525C4.F2BEDCB0

iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAIAAAC1JZyVAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAO
wgAADsIBFShKgAAAAZpJREFUSEvtlr9qwlAUxn/2MZQSooN9AcGhgwULBjcRunWpQwaXQqBP0KHU
0aFDB+lWEDdRiqCDg+Dq0AzVhqKvYW9iYmJNtM2gHXKn3JNzvu983z35E1tecoB1cgAOQRHRhPA5
Mi0yLYQDIUqONWn3S9SC26/6SePZ3Sp9a1ugsdyI2xkab5vlTuWWmuGAbNnFPZWI50k7AUlm1LQ3
3vgqpFZZGL6WbtF02sRTTqpGZsBYIrkKFMhKGF3r2qA141rzgGqUZoz8D277bCYscihWtlJk3Ebo
O7fg0mXiAzoOUL9NpuoKFVJaD0HTsU3TZWTYuOc5hjWmH2SKZn0yZbK6q0YLR5AQCv2VUJ/lN2n9
Hokz06KEwRT0JgvZ7Fqwfk02MJ7qdgfKHfM6ehCL7/dG4JJHEYPQsyqFPrjQTNaf/QpBMqrGlcxL
LZAk4LPWZS5xe+MOldBXenRYN9F23PIkBjye4tjFLK1719/NkvUoe4n0CmN4reyQIm7Fol+O3Qb9
dqD/jrK34lhv6L2NhUqI1ISwLTLt/5r2DaVEbSU4LvnuAAAAAElFTkSuQmCC

We can decode BASE64 to file and we can see that the file size is equal to extracted from Aspsoe.Email (501 bytes)