1 Reply Latest reply on May 20, 2014 5:00 PM by 2621135

    issue with MessageCountListener



      Iam writing below code to get notified whenever the new mail arrives to my inbox.

      first i've sent an email to this email then iam getting subject of the email only once as per the code.

      If iam sending again one more email then iam getting subject of the second email twicce and if iam sending again one more email then iam getting subject of third email thrice.

      But if iam just printing a debug message(the commented line) with out accessing email, then it is printing only once if i send email first time, second time, ...

      so issue is happening only when accessing email in messagesAdded() method. the event is firing for two times, three times...

      Tried with inbox.idle(), inbox.idle(false) and inbox.idle(true). Can i get any help on this.




                      inbox.addMessageCountListener(new MessageCountListener(){



                          public void messagesAdded(MessageCountEvent event){



                              Message[] msgs = event.getMessages();

                              for(Message msg:msgs){

                                  try {



                                  } catch (MessagingException ex) {

                                      Logger.getLogger(JavaApplication2.class.getName()).log(Level.SEVERE, null, ex);









                          public void messagesRemoved(MessageCountEvent mce) {

                              throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.