我正在尝试从收件箱中检索子文件夹和消息,但我只能检索父子文件夹,也尝试使用PersonalNamespaces [0]

var inbox = client.Inbox;
inbox.Open (FolderAccess.ReadWrite);

Debug.WriteLine ("Total messages: {0}", inbox.Count);
//client.Inbox.Status(StatusItems.Unread);
//Debug.WriteLine("Recent messages: {0}", inbox.Unread);
//Debug.WriteLine("Recent messages: {0}", inbox.FirstUnread);

var personal = client.GetFolder(client.PersonalNamespaces[0]);

foreach (var folder in inbox.GetSubfolders(false))
{
        Console.WriteLine("[folder] {0}", folder.Name);
        folder.Open(FolderAccess.ReadOnly);

最佳答案

并非所有IMAP服务器甚至都允许INBOX文件夹的子文件夹。如果您确定IMAP帐户的INBOX文件夹包含子文件夹,则可以使用以下代码片段获取它们:

foreach (var folder in client.Inbox.GetSubfolders (false)) {
    Console.WriteLine ("[folder] {0}", folder.Name);
}

关于c# - 检索IMAP子文件夹,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30443976/

10-10 09:14