title: Problems retrieving emails from gmail in Android app
body: <p>I'm using the java mail api built into java to get the mail of a user from their gmail box, most of the code i found in <a href="https://stackoverflow.com/questions/5928608/reading-the-full-email-from-gmail-using-javamail">another SO question</a>. And I'm able to pull most of the information i want correctly, like the subject, senders and other info from my mailbox.</p>
  <p>Everything works great except when i go to pull the &quot;content&quot; of the message it doesnt always pull the content of the message. Only like 1 in 10 times it works. The other 9 times it just finds &quot;<code>javax.mail.internet.MimeMultipart@40e9c920</code>&quot;</p>
  <p>My code is below. I'm printing the output into <code>LogCat</code> to test. Thanks in advance.</p>
  <pre><code>Properties props = System.getProperties();
              Session session = Session.getDefaultInstance(props, null);
              Store store = session.getStore(&quot;imaps&quot;);
              store.connect(&quot;imap.gmail.com&quot;, &quot;Email address here&quot;,
                      &quot;password here&quot;);
              Folder inbox = store.getFolder(&quot;Inbox&quot;);
              inbox.open(Folder.READ_ONLY);
              Message messages[] = inbox.getMessages();
              for (Message message : messages)
                  Log.d(&quot;Email&quot;, message + &quot;&quot;);
              Message message[] = inbox.getMessages();
      
                      for (int i = 0; i &lt; 25; i++) {
                          Log.d(&quot;From&quot;, message[i].getFrom()[0] + &quot;&quot;);
                          Log.d(&quot;Subject&quot;, message[i].getSubject() + &quot;&quot;);
                          String content = message[i].getContent().toString();
                          Log.d(&quot;content&quot;, content + &quot;&quot;);
                          
                      }
  </code></pre>
  <p>Edit:
  After some additional research I've found it has something to do with reading a multipart email with JavaMail</p>