MailKit icon indicating copy to clipboard operation
MailKit copied to clipboard

Can't Delete message from GMail

Open yuribb opened this issue 10 years ago • 3 comments

Hello. I trashed a message and tried to Expunge it. But message still is in trash folder. Code:

var result = mailFolder.MoveTo(uniqueIds, trashFolder);
mailFolder.CloseAsync(true);
if (trashFolder.IsOpen) trashFolder.Close(false);
trashFolder.Open(MailKit.FolderAccess.ReadWrite);
trashFolder.SetFlags(result.Source, MailKit.MessageFlags.Deleted, true);
trashFolder.Expunge(result.Source);
trashFolder.Close(true);

How can i expunge the trash folder?

yuribb avatar Aug 17 '16 16:08 yuribb

result.Source refers to the UIDs in the mailFolder and not the trashFolder. You want to use result.Destination when settings flags/expunging the trashFolder.

Hope that helps.

jstedfast avatar Aug 17 '16 21:08 jstedfast

Also what looks kind of wrong... mailFolder.CloseAsync(true); You need await mailFolder.CloseAsync(true); or ugly mailFolder.CloseAsync(true).Wait();

DavidKarlas avatar Aug 18 '16 06:08 DavidKarlas

Thank you for answer. It is really helped me.

yuribb avatar Aug 18 '16 11:08 yuribb