views:

169

answers:

1

Hi all,

i am receiving emails from the server using the IMAP protocol like it is described here. This is working very fine and i can store the emails and attachments on the disk.

Question: Do i have the possibility to delete files from the Server, so that they are no longer available, when a client tries to receive all emails? if so, please tell me how.

Greetings

+2  A: 

You should be able to do this via the standard APIs.

First you need to get a reference to the Message (or messages) you want to delete - if you're successfully reading them then you're already able to do this. Now, there's no explicit delete() operation, but you can mark a message as deleted like so:

message.setFlags(Flags.Flag.DELETED, true);

This will mark the message as deleted (which is typically what a delete operation will do in a desktop IMAP client). In order to force the deleted messages to be expunged, when you're finished with the Folder(s) in which they reside, call

folder.close(true);

where the true flag instructs the server to expunge all deleted messages.

And voila! The client should no longer see these messages when he connects to the server with any IMAP client.

Andrzej Doyle
Thanks, this is will use
Markus Lausberg