简体   繁体   English

使用Mailkit删除imap文件夹

[英]delete imap folder using Mailkit

I am using the Mailkit for .net and am having trouble to delete a IMAP-folder that I created by Code. 我正在使用Mailkit for .net,但无法删除由代码创建的IMAP文件夹。 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? 获取FolderNotFoundException,但是文件夹仍然存在吗? Need a little help or tip how to do ... (Sorry for this bad english :)) 需要一点帮助或提示如何做...(对不起,英语不好:)

Program.Client.GetFolder("mailkit"); is throwing a FolderNotFoundException because the folder doesn't exist. 因为该文件夹不存在而抛出FolderNotFoundException 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. 您需要将文件夹的完整路径提供给ImapClient.GetFolder(string path) ,但您只需要提供文件夹的名称即可。

Here's how to get the "mailkit" folder: 这是获取“ mailkit”文件夹的方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM