java - JavaMail - getMessageCount changes after opening imap folder? -


i'm writing program connects gmail , checks number of messages in inbox. if call getmessagecount() on unopened folder, returns 554, after opening it, returns 541. why difference?

by way, i'm trying check deleted messages (that have not been expunged) , recover them if possible.

edit: example code:

session session = session.getdefaultinstance(system.getproperties()); store store = session.getstore("imaps"); store.connect("imap.googlemail.com", 993, email, password); folder inbox = store.getfolder("inbox"); system.out.println(inbox.getmessagecount()); inbox.open(folder.read_only); system.out.println(inbox.getmessagecount()); 

edit: protocol trace:

(in meantime got more emails numbers different above)

debug: setdebug: javamail version 1.5.2 debug: getprovider() returning javax.mail.provider[store,imaps,com.sun.mail.imap.imapsslstore,oracle] debug imaps: mail.imap.fetchsize: 16384 debug imaps: mail.imap.ignorebodystructuresize: false debug imaps: mail.imap.statuscachetimeout: 1000 debug imaps: mail.imap.appendbuffersize: -1 debug imaps: mail.imap.minidletime: 10 debug imaps: trying connect host "imap.googlemail.com", port 993, isssl true * ok gimap ready requests <ip> vt17mb17567619iec a0 capability * capability imap4rev1 unselect idle namespace quota id xlist children x-gm-ext-1 xyzzy sasl-ir auth=xoauth auth=xoauth2 auth=plain auth=plain-clienttoken a0 ok thats wrote! vt17mb17567619iec debug imaps: auth: xoauth debug imaps: auth: xoauth2 debug imaps: auth: plain debug imaps: auth: plain-clienttoken debug imaps: protocolconnect login, host=imap.googlemail.com, user=<email>, password=<non-null> debug imaps: authenticate plain command trace suppressed debug imaps: authenticate plain command result: a1 ok <email> authenticated (success) a2 capability * capability imap4rev1 unselect idle namespace quota id xlist children x-gm-ext-1 uidplus compress=deflate enable move condstore esearch utf8=accept a2 ok success a3 list "" inbox * list (\haschildren) "/" "inbox" a3 ok success a4 status inbox (messages recent unseen uidnext uidvalidity) * status "inbox" (messages 585 recent 0 uidnext 3389 uidvalidity 2 unseen 0) a4 ok success 585 debug imaps: connection available -- size: 1 a5 examine inbox * flags (\answered \flagged \draft \deleted \seen $phishing $forwarded nonjunk $notphishing junk) * ok [permanentflags ()] flags permitted. * ok [uidvalidity 2] uids valid. * 548 exists * 0 recent * ok [uidnext 3389] predicted next uid. * ok [highestmodseq 687472] a5 ok [read-only] inbox selected. (success) 548 


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -