We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Attachments from EML are extracted as Base64

Hello Aspose Support Team,

we use Aspose to extract attachments from the EML files.

We use Mail for Java 2.3.0 library to access attachments within of an EML mail.

The issue we’ve found is, that by some EML’s attachments have been extracted as txt files containing base64 characters.

To reproduce this use attached test.eml (you need to extract it from the ZIP). If you open it with your web-client, you’ll see it contains 5 PDF attachments. Use it to run this java code and as result in the directory “extracted_attachments”: you’ll find 5 documents, which are stored as PDF, but in fact they are TXT-files with base64 stream.

InputStream readerInputStream = new FileInputStream(new File("./test.eml"));

MailMessage message = MailMessage.load(readerInputStream,


//Extract attachments

AttachmentCollection attachments = message.getAttachments();

if (attachments!=null && attachments.size()==0) {

File attachmentsDir = new File("./output/extracted_attachments");


for (int i = 0; i< attachments.size(); i++) {

Attachment attachment = (Attachment)attachments.get(i);

String attachmentDestination = "./output/extracted_attachments/" + attachment.getName();





This issue is very urgent and critical for us, because we need the fix for an important customer presentation.

Thanks in advance for your help!

Best regards

Hi Vitali,

Thanks for contacting to Aspose.Email support team.

I have analyzed the data and re-produced the issue using sample EML and code. It was also confirmed that attachments are converted to base64 text files. These text files were decoded from base64 and PDF files were retrieved properly.

I have passed all this information to the development team and will write back here on forum as soon as some feedback is received from the developers. I have also informed the development team about the urgency and marked this issue as high priority.

This issue is logged as NETWRKJAVA-33201 in our issue tracking system
We are sorry for the inconvenience caused to you.

The issues you have found earlier (filed as NETWRKJAVA-33201;NETWRKJAVA-33201) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.