In the javamail API, i have a problem with a method called getContent().
Everything written after this works EXCEPT getContent() (wich fetches the content of an email)
 
      try {
 
        // Get the inbox
        Folder inbox = mailUser.getInbox();
       
        // Get the messages from the inbox
        Message[] msgs = inbox.getMessages();
       
        // Get the requested message
        Message m = msgs[msg];
 
        // Show the date
        out.println("Date: " + m.getSentDate() + "<br>");
       
        // Show the from addresses.
        Address a[] = m.getFrom();
        out.println("From: " + formatAddresses(a) + "<br>");
 
        // Show the to addresses
        a = m.getRecipients(Message.RecipientType.TO);
        out.println("To: " + formatAddresses(a) + "<br>");
 
        // Show the copy addresses
        a = m.getRecipients(Message.RecipientType.CC);
        out.println("Cc: " + formatAddresses(a) + "<br>");
 
        // Show the subject
        String s = m.getSubject();
        if (s == null) {
          s = "";
        }
        out.println("Subject: <b>" + s + "</b><br><hr>");
 
        // Display the message
        Object o = m.getContent(); // Sometimes getContent() returns a IOException
       
        // Figure out what kind of message we have
        if (m.isMimeType("text/plain")) { blah blah blah ...............;
 
------------------------------- end of code
 
Sometimes getContent() returns a IOException. It seems to do it randomly, i've been working on this for a week, the server is still connected, the folder, and store (to those familiar with tha API) are not null, nor is Message m, i just randomly catch an exception !!!
It's weird, cause i can still get the subject, date and recipients, but not the content.... Help !
         

Reply via email to