When we are trying to load the email and extract attachments from it, for some email we are not able to
extract the attachment using MailMessage object.
The attachment is a csv file with the below content information.
It is not getting extracted either by using MailMessage.getAttachments() or by MailMessage.getLinkedResources(). Both are resulting into empty AttachmentCollection or LinkedResourceCollection respectively.
Can you help us ? We are using aspose email java(17.8)
LinkedResourceCollection linkedResourceCollection = message.getLinkedResources();
if(linkedResourceCollection != null) {
for(LinkedResource linkedResource : linkedResourceCollection) {
// process
}
}
The source eml file is confidential could we work with this given information?
Hi @sergey.vivsiuk,
Tried the vesion of code you suggested
Didn’t receive any linked resources in the alternate views also
View (text/html; charset=“utf-8”) Linked Resources Count is : 0
View (text/plain; charset=“utf-8”) Linked Resources Count is : 0
but when I manually change the content from
Content-Type: text/plain; charset=“utf-8”
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=“1936909.csv”
to
Content-Type: text/plain; charset=“utf-8”
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=“1936909.csv”
I am able to extract the csv file. That is a manual eml file change which I want to avoid.
Email clients are ignoring the attachment due to format mismatch.
To troubleshoot this issue, it is important to ensure that the message is properly formatted using the multipart/alternative structure and Content-Disposition inline.
The multipart/alternative content type is used in email communication to provide alternative versions of the same message, allowing the recipient’s email client or program to choose the most suitable format for display. This is especially useful when the sender wants to accommodate different email clients with varying capabilities or preferences.
The basic idea behind multipart/alternative is to include multiple versions of the same content within a single email message. Each version is encapsulated within a separate body part, and the email client selects the most appropriate version based on its capabilities.
Typically, a multipart/alternative message consists of two or more body parts, each representing an alternative version of the content. For example, a common use case is to include both plain text and HTML versions of the email. The email client then chooses the appropriate version to display based on its capabilities. If the client can render HTML, it will display the HTML version; otherwise, it will fall back to displaying the plain text version.
Here’s an example of how a multipart/alternative message might look:
The Content-Disposition header with the value “inline” is used in MIME email messages to specify that the content should be displayed within the body of the message itself, rather than being treated as an attachment. This header is typically used when embedding images or other media files within an HTML email.
When “inline” is specified as the content disposition, the email client is expected to display the content directly within the email message. This allows the recipient to view the content seamlessly as part of the message, without having to open or download any attachments separately.
Hi @sergey.vivsiuk,
We get “inline” images as part of LinkedResourceCollection but we are not getting the csv as part of that.
Can we expect a solution for this?
@hruser
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): EMAILJAVA-35189
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.