Free Support Forum - aspose.com

Multipart/related part marked with content-dispotion attachment missing in MailMessage

I’m trying to parse an eml email consisting of 2 parts (multipart/mixed).

First part is a multpart/alternative with a text/html and text/plain part.

The second part is a multipart/related with content-Disposition attachment.
Content-Type: multipart/related; name=“somename.mhtml”
Content-Disposition: attachment; filename=“somename.mhtml”

When I parse the mail and I can find the content from the first part by requesting the getbody or gethtmlbody.

But I can’t find the second part any where. Both attachments and linkedresources are empty.

@steffenvk,

I have observed the issue shared by you and request you to please share the source file, used sample code and explanation that which part of email is not getting fetched. Please also try using latest Aspose.Email for Java 20.4 as on your end first as well.

Example file:
example.zip (723 Bytes)

Code I’m using (the message variable is the inputstream to the file):

EmlLoadOptions emlLoadOptions = new EmlLoadOptions();
MailMessage eml = MailMessage.load(message, emlLoadOptions);
String body = eml.getBody();
String htmlBody = eml.getHtmlBody();
AttachmentCollection attachments = eml.getAttachments();
LinkedResourceCollection linkedResources = eml.getLinkedResources();

The parts I’m getting are the 2 multipart alternatives via getbody and gethmlbody
The part I’m missing is:

Content-Type: multipart/related; name="somename.mhtml"
Content-Disposition: attachment; filename="somename.mhtml" 

Which I would expect to find in the list of attachments. All of this is tested with version 20.4.

@steffenvk,

Can you please provide the output that you are getting on your end using latest Aspose.Email for .NET 20.4 along with desired output.

I’m not a .NET developer so I can’t test that. But when I run it with Aspose.Email for Java 20.4 the results are:

body = “\r\n\r\nSome text content\r\n”
htmlBody = “

somehtml content

attachments = empty Collection
linkedResources = empty Collection

The body and htmlBody are as expected
But in the attachments I would expect 1 attachment called somename.mhtml

with the content:

From:
Subject: subject
Date: Wed, 23 Apr 2020 10:00:20 -0000
MIME-Version: 1.0
Content-Type: multipart/related;
type=“text/html”;
boundary="----MultipartBoundary–KJBtzjZ2QRZaLTtDoFGL5s4ZvbJh6rByRnyPhLJfzZ----"

------MultipartBoundary–KJBtzjZ2QRZaLTtDoFGL5s4ZvbJh6rByRnyPhLJfzZ----
Content-Type: text/html
Content-Transfer-Encoding: 7bit

HELLO WORLD
------MultipartBoundary--KJBtzjZ2QRZaLTtDoFGL5s4ZvbJh6rByRnyPhLJfzZ------

@steffenvk,

I have observed the issue shared by you and a ticket with ID EMAILJAVA-34701 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

The issues you have found earlier (filed as EMAILJAVA-34701) have been fixed in this update.

1 Like