title: How to mark messages that are received by an java application using javax Mail Api?
body: <p>I want to create an application that gets all e-mails from an e-mail account using imap.
  When I first run the application I get all mails, than if I run it again I want to mark the messages that was read before so I can receive only new messages.</p>
  
  <p>I found that Message Object contains Flags(System Flags and User defined flags), but I can't manage to set one user defined flag.</p>
  
  <p>It is possible to mark the messages received by my application on the e-mail account, or I have to retain all message ids and every time when I get messages from imap I have to compare their id with retained ids and get only the messages that has different ids?</p>