Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting message from folder in javamail

Tags:

jakarta-mail

I am trying to remove/delete a message from a folder in Java mail (after I have copied it to another) here is my code:

Flags deleted = new Flags("DELETED");  
folder.setFlags(messages, deleted, true);  
folder.expunge();

The message is not affected. Can someone please show me the proper way to do this?

like image 630
Bradley Trager Avatar asked Nov 29 '12 21:11

Bradley Trager


People also ask

Is JavaMail still used?

A: Yes. The JavaMail API implementation is completely free and open source and you can include it in your product. This release includes IMAP, POP3, and SMTP providers as well.

What is JavaMail API?

The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API is available as an optional package for use with the Java SE platform and is also included in the Java EE platform.


1 Answers

Flags deleted = new Flags(Flags.Flag.DELETED);
folder.setFlags(messages, deleted, true);
folder.expunge(); // or folder.close(true);
like image 197
Bill Shannon Avatar answered Sep 28 '22 17:09

Bill Shannon