Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9237543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:33:29+00:00 2026-06-18T07:33:29+00:00

I have a client program (uses javax API) which will download attachments from an

  • 0

I have a client program (uses javax API) which will download attachments from an email. Unfortunately the same is not able to download from a specific sender.

Here is the client code which will save attachments to local disc:

String disp = p.getDisposition();
String contentType = part.getContentType();
if (disposition == null) { 
 if ((contentType.length() >= 10) && (contentType.toLowerCase().substring(0, 10).equals("text/plain"))) {
  //handle plain text
 } else { 
  part.writeTo(System.out);
 }
} else if (disposition.equalsIgnoreCase(Part.ATTACHMENT)) {
 saveFile(part.getFileName(), part.getInputStream());
} else if (disposition.equalsIgnoreCase(Part.INLINE)) {
 saveFile(part.getFileName(), part.getInputStream());
} else { // Should never happen
 // handle else block
}

Please suggest me a way to download attachment..

Below are my findings for the email that I am unable to download attachments:

  • ‘disp’ is null.
  • contentType is message/rfc822.

Below is output for part.writeTo(System.out):

MIME-Version: 1.0
Content-Type: message/rfc822

Received: from  XXXXXX with ESMTP id XXXXXXX ;          Tue, 29 Jan 2013 13:53:39 -0500
From: XXXXXXX@XXXXX.com
To: XXXXXXX@XXXXX.com
Subject: XXXXXXX
Date: Tue, 29 Jan 2013 13:53:40 -0500
Message-ID: <XXXXX.XXXXXX-XXXXXXX.XXXXXXXX@LocalDomain>
X-Priority: 1 (High)
Return-Receipt-To: <XXXXX@XXXXXX.com>
Disposition-Notification-To: <XXXXXX@XXXXXXX.com>
MIME-Version: 1.0
X-MIMETrack: Itemize by SMTP Server on XXXXXXX/XXXXXX(Release 8.5.1FP1|January 05, 2010) at 01/29/2013 01:53:39 PM
X-Disclaimed: 56875
Content-Type: multipart/mixed; boundary="----=_NextPart_145_1257127098"


------=_NextPart_145_1257127098
Content-Type: application/pdf; name="attach1.pdf"; charset="iso-8859-1"
Content-Disposition: attachment; filename="attach1.pdf"
Content-Transfer-Encoding: base64

D1//AAVP/wCR8194f27kn/Q4yv8A8OGE/wDl3mvvIiCv3Qeevf6etAGcEgggjJPfFS7H/ut/3yf8
KNj/AN1v++T/AIUfVsT/ANA9f/wVP/5HzX3h/buSf9DjK/8Aw4YT/wCXea+8bSE4/P8AKn7H/ut/
3yf8KNjf3G/75P8AhR9WxP8A0D1//BU//kfNfeH9u5J/0OMr/wDDhhP/AJd5r7xmen480uPb/P8A
kU7Y39xv++T/AIUbH/ut/wB8n/Cj6tif+gev/wCCp/8AyPmvvD+3ck/6HGV/+HDCf/LvNfeNpMjp
kZp+x/7rf98n/Ck2N12HP+6f8KPq2J/6B6//AIKn/wDI+a+8P7dyT/ocZX/4cMJ/8u8194maQkgc
/wCP0f8ADtL9m/8A6F+D/wAAY/8A4/RRQFl2/rT/ACQf8O0v2b/+hfg/8AY//j9H/DtL9m//AKF+
D/wBj/8Aj9FFAWXb+tP8kH/DtL9m/wD6F+D/AMAY/wD4/R/w7S/Zv/6F+D/wBj/+P0UUBZdv60/y
Pg0Kc3RhcnR4cmVmDQoyNjY5Mg0KJSVFT0Y=


------=_NextPart_145_1257127098
Content-Type: application/pdf; name="attach-2.pdf"; charset="iso-8859-1"
Content-Disposition: attachment; filename="attach-2.pdf"
Content-Transfer-Encoding: base64

NBclCFEsQwtbRDmKbBROiSFXwAJrKJhPUAtYIG1qQGYhi2QojkKW7DAxMjXAkRaNTU1wpEUUGZQk
h2IabhnM1Ag00YieOXCQeNsQmNSx6DO21IOI4sqFyPowXA8PSAzXIwcxUn5DcwUOmaGXFY2BCkEc
jLyoAuKSmxeRTMWRGYGuQHM4MSKDJlUamVtiT5VmcOYwzY0mKFXVCCmEiIhurIUQij5U1yMHJKrr
0YIYUdSguwKHzNArhAyAZbk5tkKI7AIIycRhWgDh0GdkoQdRN1xzIg59w74AshiR5S7hVI693DU1
1DPGUrrmogYkin3oQYxUuiKbhltmyJW7RqZGcL+glbsGBqZGZJa9yKbiKHvJDhVDEyMcqdLIxAxH
qkSRQUl7KKbhlsFMlUATjeiZGQeJtw3M9Yyx6DO21IOI4sqMyPowXA8PSAzXIwcxUpZDcwUOmaGX
GY0s9QxAHIzMqGKuZ25CbmZEMhVHZgS6As3hxIgMmlRpaA4sgrGlSjM4c5jmRjOU6mqEFEJERDfW
QghFH6rrkQMS1fVoQYwoatBdgUNm6BVCBoZ6ZubYCiEzcgsgJBOHaQGEQ5+RhR5E3XDNiTj0DfsC
NQ0KL0luZm8gMSAwIFINCi9Sb290IDIgMCBSDQo+Pg0Kc3RhcnR4cmVmDQo0ODYzMA0KJSVFT0Y=


------=_NextPart_145_1257127098
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="iso-8859-1"

Dear XXXXXX,

Please see attached for your most recent attachments.  Please direct correspond=
ence and inquiries to accounts=XXXXX@XXXX.com.
=20
Thank you for your continued support, we appreciate it very much.
=20
=20
Sincerely,
=20
XXXXX, XXX.

------=_NextPart_145_1257127098--
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:33:30+00:00Added an answer on June 18, 2026 at 7:33 am

    I got a workaround for my problem.

    When disposition is null and Content-type is ‘MESSAGE/XXXX’, treating that as a new message and iterate over its content.

    else  if(disp == null && StringUtils.isNotBlank(contentType) && contentType.toLowerCase().substring(0, 7).equals("message")) {
        IMAPNestedMessage msg = (IMAPNestedMessage) p.getContent();
        Part p2 = (Part) msg;
        Multipart mp = (Multipart) p2.getContent();
        int count = mp.getCount();
        for (int i = 0; i < count; i++){
            addAttachment(mp.getBodyPart(i), fileNames, fileName);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program that uses webDAV to download documents from a sharepoint
I have had a bug report from a client. My program uses the Delphi
I have a java client program that uses mdns with service discovery to find
We have a client which uses http-outboundgateway to place REST calls <int-http:outbound-gateway request-channel=glNewsRequestChannel url=${gl.url}
I have the following algorithm implemented in Java which uses TCP/IP: -Client request a
I have a client-server program that uses sockets to transfer information in a stateful
I have been tasked with writing a program which will run a set of
I have a Java program which uses ZeroMQ sockets for inter-process communication. I have
So I have a client and a server Java program. The client uses Java
I have a Client program by tcp connection that send data to a server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.