{"id":1239,"date":"2010-10-25T15:09:04","date_gmt":"2010-10-25T13:09:04","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1239"},"modified":"2015-11-08T23:30:36","modified_gmt":"2015-11-08T21:30:36","slug":"list-all-folders-using-imap","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/list-all-folders-using-imap","title":{"rendered":"List all folders using IMAP"},"content":{"rendered":"<p>IMAP protocol sometimes calls folders mailboxes. It&#8217;s not very fortunate as mailbox usually means email address (john.smith@example.com) or account attached to an email address.<\/p>\n<p>You can use Mail.dll <a href=\"\/mail\">.NET IMAP component<\/a> to retrieve a list of all IMAP folders existing on the server, by using <em>GetFolders <\/em>method. It returns a list of <em>FolderInfo <\/em> objects. You can use this object to get a folder name (<em>FolderInfo.Name<\/em>). You can also use <em>FolderInfo <\/em> instance as a parameter for <em>SelectFolderInfo()<\/em> method to access this folder.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C# version:\r\n\r\nusing Limilabs.Mail;\r\nusing Limilabs.Client.IMAP;\r\nusing System;\r\n\r\nclass Program\r\n{\r\n    static void Main(string&#x5B;] args)\r\n    {\r\n        using (Imap imap = new Imap())\r\n        {\r\n            imap.Connect(&quot;imap.example.com&quot;);   \/\/ or ConnectSSL\r\n            imap.UseBestLogin(&quot;user&quot;, &quot;password&quot;);\r\n\r\n            foreach (FolderInfo folder in imap.GetFolders())\r\n            {\r\n                Console.WriteLine(folder.Name);\r\n            }\r\n            imap.Close();\r\n        }\r\n    }\r\n};\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET version:\r\n\r\nImports Limilabs.Mail\r\nImports Limilabs.Client.IMAP\r\n\r\nPublic Module Module1\r\n    Public Sub Main(ByVal args As String())\r\n\r\n        Using imap As New Imap()\r\n            imap.Connect(&quot;imap.example.com&quot;)  ' or ConnectSSL\r\n            imap.UseBestLogin(&quot;user&quot;, &quot;password&quot;)\r\n\r\n            For Each folder As FolderInfo In imap.GetFolders()\r\n                Console.WriteLine(folder.Name)\r\n            Next\r\n            imap.Close()\r\n        End Using\r\n\r\n    End Sub\r\nEnd Module\r\n<\/pre>\n<p>FolderInfo object contains detailed information about the folder (Name, SeparatorChar, Flags)<\/p>\n<p>You can read more about <a href=\"\/blog\/folder-management-using-imap-create-delete-rename\">folder management using IMAP<\/a>.<\/p>\n<p>On some servers it is possible to <a href=\"\/blog\/common-imap-folders\">get information about the purpose (spam, sent items) of each IMAP folder<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IMAP protocol sometimes calls folders mailboxes. It&#8217;s not very fortunate as mailbox usually means email address (john.smith@example.com) or account attached to an email address. You can use Mail.dll .NET IMAP component to retrieve a list of all IMAP folders existing on the server, by using GetFolders method. It returns a list of FolderInfo objects. You [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,28,77,57],"class_list":["post-1239","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-imap","tag-imap-component","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1239"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=1239"}],"version-history":[{"count":7,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1239\/revisions"}],"predecessor-version":[{"id":4983,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1239\/revisions\/4983"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}