title: How to read text inside body of mail using javax.mail
body: <p>i'm developing a client mail using javax.mail to read mail inside mail box:</p>
  
  <pre><code>Properties properties = System.getProperties();  
  properties.setProperty("mail.store.protocol", "imap");  
  try {  
      Session session = Session.getDefaultInstance(properties, null);
      Store store = session.getStore("pop3");//create store instance  
      store.connect("pop3.domain.it", "mail.it", "*****");  
      Folder inbox = store.getFolder("inbox");  
      FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
      inbox.open(Folder.READ_ONLY);//set access type of Inbox  
      Message messages[] = inbox.search(ft);
      String mail,sub,bodyText="";
      Object body;
      for(Message message:messages) {
          mail = message.getFrom()[0].toString();
          sub = message.getSubject();
          body = message.getContent();
          //bodyText = body.....
      }
  } catch (Exception e) {  
      System.out.println(e);    
  }
  </code></pre>
  
  <p>I know that the method <code>getContent()</code> returns an object cause the content could be a <code>String</code>, a <code>MimeMultiPart</code>, a <code>SharedByteArrayInputstream</code> and other ( i think )... Is there a way to get always the text inside body of message? Thanks!! </p>