开发者

Help in deleting the messages from inbox folder

I'm trying to delete the messages which is selected by user by clicking the checkbox and then clicking the delete button, but I don't understand why my code is not performing the desirable result. Here's the code in Javamail:

public static boolean deleteMessage(int j) throws Exception
 { 

 store = session.getStore("pop3");
store.connect("localhost", "red","red");



 inbox = store.getFolde开发者_StackOverflow社区r("INBOX");
inbox.open(Folder.READ_WRITE);


    msgs[j].setFlag(Flags.Flag.DELETED, true); // set the DELETED flag

      if (msgs[j].isSet(Flags.Flag.DELETED))
    {
    inbox.close(true);
    return true; 
    }
    return false;
}

The above method is calling every time based on how many messages selected by user to delete. If there two messages selected by user to delete, then it will be called twice. Passing those numbers as a parameter in the deleteMessage method by calling method class. But it's not doing anything, nor it's throwing any exception. What's wrong I'm doing?


Try

Message msg = inbox.getMessage(j);
msg.setFlag(Flags.Flag.DELETED, true);
if (msg.isSet(Flags.Flag.DELETED))
{
    inbox.close(true);
    return true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜