Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [javamail-dev] getMessageCount returning wrong value

As I said in my answer to your other email...
Why exactly do you think the count is wrong?  How are you determining
the number of messages without using JavaMail?

As you can see from the debug output, JavaMail is telling you exactly what
the server is telling JavaMail.

Is it possible that there are deleted but not expunged messages in the
folder and your mailer is not showing them to you?

Ramonrune wrote on 10/05/2018 10:31 AM:

I'am reading a Amazon WorkMail folder using javax.mail v1.4, and getMessageCount from folders class is returning wrong values (per example, instead of 15 e-mails, 33 are being returned). Here is the code:

Session session = Session.getInstance(props);
Store store = session.getStore(mail.getMailProtocol().getProtocol());
store.connect(mail.getMailProtocol().getHost(),mail.getMailProtocol().getUser(),
                            mail.getMailProtocol().getPassword());

Folder inbox = store.getFolder(mail.getMailProtocol().getFolder());
inbox.open(Folder.READ_WRITE);
System.out.println(inbox.getMessageCount());

I'm using imap protocol, using the following properties:

props.setProperty("mail.store.protocol", "imaps");
props.put("mail.imaps.ssl.trust", "*");

Obs: I'am reading INBOX folder.

Can someone help me to find if there is something wrong ? Thanks folks!

Edit 1

Here is some debug from java mail, there is only 3 emails, but getMessageCount shows 15

A1 OK Logged in
 DEBUG: connection available -- size: 1
 A2 SELECT INBOX
 * FLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded)
 * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded)] 
 Flags permitted.
 * 15 EXISTS
 * 0 RECENT

--
Best regards,
Ramon Lacava Gutierrez Gonçales


_______________________________________________
javamail-dev mailing list
javamail-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/javamail-dev


Back to the top