Autor Beitrag
Raven280438
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 99



BeitragVerfasst: Do 27.10.11 13:39 
Hi,

ich möchte mit ImapX alle Ordner eines IMAP-Postfachs anzeigen.
ausblenden C#-Quelltext
1:
ImapX.FolderCollection collection = this.Client.GetFolders();					

bringt leider nur die Unterordner, die maximal 1 Ebene tief sind, der Rest wird nicht angezeigt.

Ich hab dran gedacht, eine rekursive Funktion zu schreiben, leider funktioniert das auch nicht so richtig.
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
public List<String> GetFolders()
        {
            List<String> returnlist = this.GetFoldersRecursive(String.Empty);

            returnlist.Sort();

            return returnlist;
        }

        private List<String> GetFoldersRecursive(String folder)
        {
            List<String> ret = new List<String>();

            folder = folder.Trim(new char[] { '\\''/' });

            ImapX.FolderCollection collection;

            if (folder == String.Empty)
            {
                collection = this.Client.GetFolders();
            }
            else
            {
                collection = this.Client.Folders[folder].SubFolder;
            }

            foreach (ImapX.Folder fold in collection)
            {
                List<String> sub = this.GetFoldersRecursive(fold.FolderPath);
                foreach (String subfolder in sub)
                {
                    if (!ret.Contains(subfolder))
                    {
                        ret.Add(subfolder);
                    }
                }
            }

            return ret;
        }


Hat jemand Erfahrung mit ImapX (oder einer anderen kostenlosen IMAP-Dll) und kann mir bei diesem Problem helfen?


Gruß