0
votes

I am using the Mailkit for .net and am having trouble to delete a IMAP-folder that I created by Code. This is my sample code: Created the folder like this:

var personal = Program.Client.GetFolder (Program.Client.PersonalNamespaces[0]);
            var mailkit = personal.Create("mailkit", false);
            var archive = mailkit.Create("archive", true);
            var flagged = mailkit.Create("flagged", true);
...

Tried to delete the Folder again like this:

    var temp = Program.Client.GetFolder("mailkit");
    temp.Delete();

Get an FolderNotFoundException, but the folder is still there? Need a little help or tip how to do ... (Sorry for this bad english :))

1
Do you get the exception in the Delete() call or the GetFolder() call? - jstedfast

1 Answers

0
votes

Program.Client.GetFolder("mailkit"); is throwing a FolderNotFoundException because the folder doesn't exist. You need to provide the full path of the folder to ImapClient.GetFolder(string path), but instead you have only provided the folder's name.

Here's how to get the "mailkit" folder:

var personal = Program.Client.GetFolder (Program.Client.PersonalNamespaces[0]);
var mailkit = personal.GetSubfolder ("mailkit");