I want to delete some messages in my mailbox. When a message is read the DELETED flag was set as, message.setFlag(Flags.Flag.DELETED,true); folder.Expunge(); As per the documentation,folder.Expunge() method will look for all the messages in the folder whose DELETED flag is set. But with the above code Exception was thrown as method folder.Expunge() not supported by the implementation. How should I delete the messages I want,or get through this problem? Thanks Vikas
Lewin Chan
Ranch Hand
Joined: Oct 10, 2001
Posts: 214
posted
0
Assuming you are using the Sun POP3 implementation, and you read the sundocs, you will find that Folder.expunge is not supported... You should do Message.setFlag(Flags.Flag.DELETED), and then do a folder.close(true) to delete the messages
I have no java certifications. <br />This makes me a bad programmer.<br />Ignore my post.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 11862
posted
0
I just tried this: msg[i].setFlag( Flags.Flag.DELETED ,true );// could mark flag? msg[i].saveChanges(); // will delete when folder closed and got the following : javax.mail.IllegalWriteException: POP3 messages are read-only at com.sun.mail.pop3.POP3Message.saveChanges(POP3Message.java:380) at com.lanw.clients.TestMailRead.main(TestMailRead.java:48) The folder was opened like this: folder.open(Folder.READ_WRITE); So - now I am mystified, how can I delete a Message from a Folder? Bill
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 11862
posted
0
Aha - get to answer my own question. if I remove the line: msg[i].saveChanges(); But use the following on the folder: folder.close(true) ; Then the POP3 messages are deleted. Somehow that does not seem "instinctive"! Bill
subject: folder.Expunge() not supported exception.