title: Reading the full email from GMail using JavaMail
body: <p>I am making use of javamail and I am having trouble getting the HTML from my gmail emails. I have the following:</p>
  
  <pre><code>Session session = Session.getDefaultInstance(props, null);
  Store store = session.getStore("imaps");
  store.connect("imap.gmail.com", "myemail@gmail.com", "password");
  System.out.println(store);
  
  Folder inbox = store.getFolder("Inbox");
  inbox.open(Folder.READ_ONLY);
  Message messages[] = inbox.getMessages();
  for(Message message:messages) {
  System.out.println(message); // com.sun.mail.imap.IMAPInputStream@cec0c5
  </code></pre>
  
  <p>The above all works fine but I can't print or get the actual HTML or Text email. I just get some sort of InputStream, how do I deal with this easily to get the raw HTML of the email?</p>
  
  <p>I also tried looping through the message but that didn't get me very far:</p>
  
  <pre><code>Message message[] = inbox.getMessages();
  
      for (int i=0, n=message.length; i&lt;n; i++) {
         System.out.println(i + ": " + message[i].getFrom()[0] 
           + "\t" + message[i].getSubject());
         String content = message[i].getContent().toString();
         if (content.length() &gt; 200) 
      content = content.substring(0, 600);
         System.out.print(content);
  </code></pre>
  
  <p>}</p>
  
  <p>Thanks all for any hlep.</p>