Link to home
Start Free TrialLog in
Avatar of LeanMoreTryMore
LeanMoreTryMore

asked on

JavaMail - How do I get the Attachment name and file type

Would anyone give me the idea how to get the attachment name and its file type?

see my code below:

  protected static void handleMultipart(Multipart multipart
                                       ,String    iEmailAttachmentName
                                       ,String    iApplHomeDir
                                       ,String    iEmailSubject
                                       ,String    iIncomingEmailSubject)
      throws MessagingException, IOException {
   try {
    for (int i=0, n=multipart.getCount(); i<n; i++) {
      System.out.println("here u r ****** " + multipart.getBodyPart(i).ATTACHMENT.);
      handlePart(multipart.getBodyPart(i), iEmailAttachmentName, iApplHomeDir,iEmailSubject, iIncomingEmailSubject);
    }
   }
   catch (Throwable e) {
     e.printStackTrace();
   }
  } // handleMultipart

Avatar of Mick Barry
Mick Barry
Flag of Australia image

 String filename = multipart.getFileName();
  String contentType = multipart.getContentType();
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
should also be useful background:

http://www.jguru.com/faq/view.jsp?EID=26996