getting attachment name
2 posts in topic
Flat View  Flat View

Posted By:   ayesha_chodry
Posted On:   Friday, March 22, 2002 01:03 PM

i am unable to get the name of file attached. it alsways give 'filename'. how to get the name of file that is attached.

Re: getting attachment name

Posted By:   Jeff_Gay  
Posted On:   Friday, March 29, 2002 06:14 PM

Actually, it's not enough just to get the file name from the part as it might be encoded.
Take a look at the source code for ICEMail at www.icemail.org. You'll find a file called MessageUtilities.java. Look for the getFileName() method.

Re: getting attachment name

Posted By:   Saravankumar_S  
Posted On:   Tuesday, March 26, 2002 04:00 AM

Try out the following code.
It will work for the the IMAP also.
/*For IMAP just change the package name
as com.sun.mail.imap.IMAPMessage*/
javax.mail.internet.MimeMessage mimemsg =new javax.mail.internet.MimeMessage((com.sun.mail.pop3.POP3Message) msg);

javax.mail.internet.MimeMultipart multipart=(javax.mail.internet.MimeMultipart) mimemsg.getContent();

for(int p=0;multipart!=null&&p
javax.mail.internet.MimeBodyPart part=(javax.mail.internet.MimeBodyPart)multipart.getBodyPart(p);

String[] filename=part.getFileName();

About | Sitemap | Contact