0
안드로이드에서 javamail API를 사용하여 no.of 메시지, 삭제 된 메시지 및 no.of 전체 메시지의 세부 정보를 얻으려고합니다. 하지만 삭제 된 메시지의 수는 항상 -1이됩니다. 나는 이유/버그가 무엇인지 알 수 없으므로 이것으로 나를 도와주세요. 여기에 내 코드 클래스 Readmails 것은 당신이받은 편지함을 열기 전에 당신은 getDeletedMessageCount()
를 호출 AsyncTask를 {folder.getDeletedMessageCount()가 항상 -1을 반환하는 이유는 무엇입니까?
Folder inbox;
Folder inbox2;
Properties props = System.getProperties();
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
props.setProperty("mail.store.protocol", "imaps");
try
{
/* Create the session and get the store for read the mail. */
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com","[email protected]", "testmycode12345");
/* Mention the folder name which you want to read. */
inbox = store.getFolder("Inbox");
System.out.println("No of Unread Messages : " + inbox.getUnreadMessageCount());
System.out.println("No of New Messages : " + inbox.getNewMessageCount());
System.out.println("No of Deleted Messages : " +inbox.getDeletedMessageCount());
System.out.println("No of total Messages : " + inbox.getMessageCount());
System.out.println("No of Type Messages : " + inbox.getType());
/*Open the inbox using store.*/
inbox.open(Folder.READ_ONLY);
/* Get the messages which is unread in the Inbox*/
Message messages[] = inbox.search(new FlagTerm(new Flags(Flag.SEEN), false));
/* Use a suitable FetchProfile */
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.CONTENT_INFO);
inbox.fetch(messages, fp);
try
{
inbox.close(true);
store.close();
}
catch (Exception ex)
{
System.out.println("Exception arise at the time of read mail");
ex.printStackTrace();
}
}
catch (NoSuchProviderException e)
{
e.printStackTrace();
System.exit(1);
}
catch (MessagingException e)
{
e.printStackTrace();
System.exit(2);
}
return null;
}
}
[javadocs에서] 동일한 내용 (https://javamail.java.net/nonav/docs/api/javax/mail/Folder.html#getDeletedMessageCount)). 아무도 더 이상 javadocs를 읽지 않는 이유는 무엇입니까? –
이제 처음으로 0을 얻었고 테스트를 위해 서버에서 메시지를 삭제했지만 0을 반환했습니다. 1로 제공하지 않고 두 번째 테스트에서 두 번째 테스트를 다시 테스트하여 0을 반환합니다. – Niranjan