IMAP protocol doesn't support this directly, but it can be done this way:
- Call Imap.CopyMessage to copy a message to another IMAP folder.
- Then call Imap.DeleteMessage to mark the message in the original folder as deleted.
- To actually remove the original message, call Imap.Purge (be careful, this will purge
any other messages marked as "deleted" as well)
Sample code:
C#:
// initialize an IMAP session
Imap client = new Imap();
...
// select the source folder
client.SelectFolder("Inbox");
// copy the message to the target folder
client.CopyMessage(uniqueId, "Archive");
// mark the original message as "deleted"
client.DeleteMessage(uniqueId);
// purge deleted messages (be careful, this will purge
// any other messages marked as "deleted" as well)
client.Purge();
VB.NET:
''# initialize an IMAP session
Dim client As New Imap
...
''# select the source folder
client.SelectFolder("Inbox")
''# copy the message to the target folder
client.CopyMessage(uniqueId, "Archive")
''# mark the original message as "deleted"
client.DeleteMessage(uniqueId)
''# purge deleted messages (be careful, this will purge
''# any other messages marked as "deleted" as well)
client.Purge()