title: java.lang.ClassCastException: javax.mail.internet.MimeMultipart cannot be cast to java.lang.String         at NewClass.main(NewClass.java:34)
body: <p>This is the code that is intended to fetch up the email from Gmail server. Along with it also brings the subject and the sender separately. The inbox that i am checking has 5 messages.<em>(some read and some unread)</em> 
  I wanted the html content to be visible , so i used <code>JEditorPane</code></p>
  
  <pre><code> import javax.mail.*;
   import javax.mail.internet.*;
   import java.util.*;
   import javax.swing.*;
  
   class NewClass {
   public static void main(String args[]) {
      Properties props = new Properties();
      props.put("mail.imap.host" , "imap.gmail.com" );
      props.put("mail.imap.user" , "username");
      // User SSL
      props.put("mail.imap.socketFactory" , 993);
      props.put("mail.imap.socketFactory.class" , "javax.net.ssl.SSLSocketFactory" );
      props.put("mail.imap.port" , 993 );
      Session session = Session.getDefaultInstance(props , new Authenticator() {
          @Override
                  protected PasswordAuthentication getPasswordAuthentication() {
                          return new PasswordAuthentication("username" , "password");
          }
      });
  
      try {
        Store store = session.getStore("imap");
        store.connect("imap.gmail.com" , "username" , "password");
        Folder fldr = store.getFolder("Inbox");
        fldr.open(Folder.READ_WRITE);
        Message msgs[] = fldr.getMessages();
          for(int i = 0 ; i &lt; msgs.length ; i++) {
              // program breaks after the following statement
              System.out.println(InternetAddress.toString(msgs[i].getFrom()) + "&lt;-- FROM" + " " + msgs[i].getSubject() + "&lt;---Subject"); 
              JFrame fr = new JFrame();
              JPanel p = new JPanel();
              JEditorPane ep = new JEditorPane("text/html" , (String)msgs[i].getContent());
      ep.setEditable(false);
              JScrollPane sp = new JScrollPane(ep);
              p.add(ep);
              fr.add(p);
              fr.setSize(300,300);
              fr.setVisible(true);
          }
      } catch(Exception exc) {
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The output that i get is : 
  <code>Gmail Team &lt;mail-noreply@google.com&gt;&lt;-- FROM Get Gmail on your mobile phone&lt;---Subject</code></p>
  
  <p>After this output the program gives the following exception <code>java.lang.ClassCastException: javax.mail.internet.MimeMultipart cannot be cast to java.lang.String
          at NewClass.main(NewClass.java:34)</code>.
  Why the frame is not visible ? </p>