title: JavaMail - Parsing email content, can't seem to get it to work! (Message.getContent())
body: <p>For a few weeks I have been developing a email client for android, I have been ignoring parsing email content for a while as I have never been able to get it to work. Thus, the time has come to ask for help!</p>
  
  <p>I have been looking around and I have come across a few methods I have tried but never had much success with! Currently my closest attempt would have to be:</p>
  
  <pre><code>private String parseContent(Message m) throws Exception
  {       
      //Multipart mp = (Multipart)c;
      //int j = mp.getCount();
  
      /*for (int i = 0; i &lt; mp.getCount(); i++)
      {
          Part part = mp.getBodyPart(i);
          System.out.println(((MimeMessage)m).getContent());
          content = content + part.toString();
          //System.out.println((String)part.getContent());
      }*/
  
      Object content = m.getContent();
      String contentReturn = null;
  
      if (content instanceof String) 
      {
          contentReturn = (String) content;
      } 
      else if (content instanceof Multipart) 
      {
          Multipart multipart = (Multipart) content;
          BodyPart part = multipart.getBodyPart(0);
          part.toString();
          contentReturn = part.getContent().toString();
      }   
      return contentReturn;
  }
  </code></pre>
  
  <p>But it does not work and I get gibberish such as "javax.mail.internet.MimeMultipart@44f12450".</p>
  
  <p>Can anyone see where I am going wrong?</p>
  
  <p>Thanks,
  Rhys</p>