title: How to get gmail mails programmatically in android
body: <p>I want to get all inbox mails of different mail services like gmail, hotmail, rediffmail etc. into my application. Initially I tried to get gmail mails using Imap. But I am getting a socket exception. Here is the code I tried. Please help me.</p>
  
  <pre><code>public void getMails(View V){
  Properties props = System.getProperties();
  props.setProperty("mail.store.protocol", "imaps");
  props.setProperty("mail.imap.port", "993");
  
  props.setProperty("mail.imap.socketFactory.class", .ssl.SSLSocketFactory");
  props.setProperty("mail.imap.socketFactory.fallback", "false");
      try {
        Session session = Session.getDefaultInstance(props, null);
        Store store = session.getStore("imaps");
        store.connect("imap.gmail.com", "aravelliramesh35@gmail.com", "pswd");
      }
    //}catch (NoSuchProviderException e) {
    //   e.printStackTrace();
    //   System.exit(1);
    //} 
      catch (MessagingException e) {
          e.printStackTrace();
          System.exit(2);
      }
  }
  </code></pre>