views:

32

answers:

0

I've a class(Which I've written in Java), which is I'm using to display attached file messages from spam and inbox folder. The class successfully displaying attached file messages from inbox folder, but it is not displaying the same attached messages from spam folder. The class although successfully displaying other part of the message.

Could anyone please tell me the reason of not displaying the file content from spam folder?

EDIT: Here's the code to read those messages, I'm printing those messages, by passing PrintWriter object from servlet class.

  public static void readMessages(String number,String folder1,String protocol) 
    { 
      try{
        Integer i=Integer.decode(number);
        Store store = session.getStore(protocol);
        store.connect("localhost","[email protected]","red" );

        // Get folder
        Folder folder = store.getFolder(folder1);
        folder.open(Folder.READ_ONLY);
        Message[] message=folder.getMessages();

         response.println(i + ": "
             + message[i].getFrom()[0] 
             + "\t" + message[i].getSubject());

         Multipart multipart =(Multipart) message[i].getContent();

         for(int a=0;a<multipart.getCount();a++){

          BodyPart bodyPart = multipart.getBodyPart(a);
                    InputStream stream = bodyPart.getInputStream();
                    BufferedReader br = new BufferedReader(new InputStreamReader(stream));

                    while (br.ready()) {
                        response.println(br.readLine());

                    }
                    response.println();
                }
                response.println();


        folder.close(true);
        store.close();
        } 
     catch(Exception e)
     { response.println("Exception occured");
       e.printStackTrace();
     }
    }