I am using MailKit (https://github.com/jstedfast/MailKit) to connect to google apps via imap, how can I delete a single message though ? (I am fine to have it moved to trash, ju
To delete a message from a folder on the IMAP server, this is all you need to do:
client.Inbox.AddFlags (new int[] { index }, MessageFlags.Deleted);
or
client.Inbox.AddFlags (new UniqueId[] { uid }, MessageFlags.Deleted);
Now the message is marked as \Deleted on the server.
You can then purge the folder of all deleted items by calling:
client.Inbox.Expunge ();
If you are using UIDs instead of indexes and the IMAP server supports the UIDPLUS extension (check the client.Capabilities), you can expunge just a selected set of messages like this:
if (client.Capabilities.HasFlag (ImapCapabilities.UidPlus))
client.Inbox.Expunge (new UniqueId[] { uid });