title: Reading Mail Content Using Java Mail API
body: <p>I am able to get the from field and subject field correctly , But i am getting the Mail Content in Object Format even though i m using toString() method..</p>
  
  <p>please check with the following source code</p>
  
  <pre><code>    try {
          Session session = Session.getInstance(props, null);
          Store store = session.getStore();
          store.connect("imap.gmail.com", "mymail@gmail.com", "****");
          Folder inbox = store.getFolder("INBOX");
          inbox.open(Folder.READ_ONLY);
          Message msg = inbox.getMessage(inbox.getMessageCount());
          Address[] in = msg.getFrom();
          for (Address address : in) {
              System.out.println("FROM:" + address.toString());
          }
  
          Object obj = msg.getContent();
          //Multipart mp = (Multipart)obj;
  
          Multipart mp = (Multipart) msg.getContent();
         // MimeBodyPart part = (MimeBodyPart)mp.getBodyPart(0);
          BodyPart bp = ((Multipart) msg.getContent()).getBodyPart(0);
  
          // Object body = msg.getContent();
  
          //String value = String.valueOf(body);
  
          System.out.println("SENT DATE:" + msg.getSentDate());
          System.out.println("SUBJECT:" + msg.getSubject());
          System.out.println("CONTENT:" + bp.getContent().toString());
      } catch (Exception mex) {
          mex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>    output console:
  
     FROM:Myname &lt;mymail@gmail.com&gt;
     SENT DATE:Tue Nov 05 12:28:24 IST 2013
     SUBJECT:test
    CONTENT:javax.mail.internet.MimeMultipart@5117f31e
  </code></pre>