• Post Reply Bookmark Topic Watch Topic
  • New Topic

folder.Expunge() not supported exception.  RSS feed

 
vikas tarade
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!