title: How to synchronize application email to server email using Java mail in Android?
body: <p>I want to change synchronously change in email application then automatic change in server email. For example, I have read the unread message on email application then automatic server email change unread mail to read mail.</p>
  
  <p>My email application has use mail jar file, activation.jar and additional jar file use and following code are use for connectivity email application to server email:</p>
  
  <pre><code>Properties props = System.getProperties();
              props.setProperty("mail.store.protocol", "imaps");
              props.put("mail.smtp.starttls.enable","true");
              Authenticator auth = new Authenticator() {
                  protected PasswordAuthentication getPasswordAuthentication(){
                      return new PasswordAuthentication("USEREMAILID","PASSWORD ");
                      }
              };
              sessioned= Session.getDefaultInstance(props, auth);
              store = sessioned.getStore("imaps");
             store.connect("smtp.gmail.com","USEREMAILID","PASSWORD ");
               inbox = store.getFolder("inbox");
              inbox.open(Folder.READ_ONLY);
              FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
              UNReadmessages = inbox.search(ft);
  </code></pre>