My application polls a specific email account and downloads email attachments to disk. I am able to successfully handle inline email attachments and outline attachments as parts (Part instanceof javamail Part).
But, there's one specific email wherein it has an attachment that is of type com.sun.mail.util.BASE64DecoderStream
.
Hence, I am not able to fetch the file name or its inputstream. Although, i can see the fileName in original message headers.
Following is the snapshot of the headers:
Date: Thu, 12 Sep 2013 13:05:29 -0400
From: SXXXXX <[email protected]>
Subject: PO 926460
Message-ID: <[email protected]>
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIKsWRWlGSWpSXmKPExsVy7Ey1ju7lL4ZBBp/nqVlsbr3K5MDosXdD
H3MAYxSXTUpqTmZZapG+XQJXRs/Cz2wFM64zVexdsIO5gXHDOaYuRk4OCQETib975jFD2GIS
F+6tZ+ti5OIQEjjGKLF3+VR2COc0o8SRNwsYQapYBLQl7nRuYgOx2QR0JOb8a2UHsYUFpCTa
Lq8FmyoioCHRuvk/2FReASOJV1ueQdmCEidnPmEBsTkFhCQ6rnaywmyesO4XM8R8Z4m316+B
7RISsJS40zyVDaJGU2LGgRtgu5gFbCWOfpkGZStKTOl+CGWrSazqWMg+gVFoFpJ1s5C0zELS
Content-Type: application/pdf; name="PO 926460.pdf"
Content-Description: PO 926460
Content-Transfer-Encoding: base64
X-MS-Exchange-Organization-AuthSource: FANUCEXCHCHI03.FAC.local
X-MS-Exchange-Organization-AuthAs: Anonymous
X-TM-AS-Product-Ver: SMEX-10.0.0.1412-7.000.1014-20144.004
X-TM-AS-Result: No--7.671100-5.000000-31
X-TM-AS-User-Approved-Sender: No
X-TM-AS-User-Blocked-Sender: No
X-MS-Exchange-Organization-AVStamp-Mailbox: SMEXr^dE;1027300;0;This mail has
been scanned by Trend Micro ScanMail for Microsoft Exchange;
X-MS-Exchange-Organization-SCL: -1
MIME-Version: 1.0
Please assist, how to fetch the filename and get input stream and thus save it to disk as file.
There's no attachment in that message. It's a single part (as opposed to multipart) message of MIME type "application/pdf". Since a MimeMessage is-a Part, just treat it the way you do an attachment Part.