Java Receive Attachment problem ?
- by Karthick RM
Hi to all.I use the following code to download the attachment from the mail .But it gives the ClassCastException  on the Multipart declaration 
  Exception in thread "main" java.lang.ClassCastException: com.sun.mail.imap.IMAPInputStream cannot be cast to javax.mail.Multipart
      at ReadAttachment.main(ReadAttachment.java:52)
  How do I handle IMAPInputStream? Thanks in advance !!!
    Message messages[] = inbox.getMessages();
         for (int j = 0; j < messages.length; j++) {
            String mailType = messages[j].getContentType();
            System.out.println("------------ Message " + (j + 1)
                    + " ------------");
            System.out.println("SentDate : " + messages[j].getSentDate());
            System.out.println("From : " + messages[j].getFrom()[0]);
            System.out.println("Subject : " + messages[j].getSubject());                
            System.out.println("Type :" + messages[j].getContentType());
            System.out.println("Attachment :" + messages[j].getFileName()); 
            Multipart mp = (Multipart) messages[j].getContent();
            ...........
            ..............
            System.out.println();
         }