如何从POP服务器删除邮件

时间:2017-05-23 15:52:55

标签: java android javamail pop

嗨男孩和女孩(当然)

我想通过他们的Message-ID从pop服务器中删除一些邮件,但它不能正常工作

我做错了什么?

MessageIDTerm[] toDelete = maildb.getMarkAsErased()
//just constructs an array from stored string by me;
if (toDelete.length>0){
    inbox.open(Folder.READ_WRITE);
    Message[] mm = inbox.search(new OrTerm(toDelete));
    for (Message m :mm) {
        m.setFlag(Flags.Flag.DELETED, true);
        maildb.deleteMail(Utils.getMessageID(m));
    }
    //inbox.delete(true); I should NOT delete de inbox folder :D LOL
    inbox.close(true);
}

修改

java mail 1.4

android build tools 23.0.3

编译android sdk 23

1 个答案:

答案 0 :(得分:0)

Finally there is a solution

I'd force to cast to POPMessage and then delete

((POPMessage)m).setFlag(Flags.Flag.DELETED, true);