{"id":1992,"date":"2011-10-06T14:46:12","date_gmt":"2011-10-06T12:46:12","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=1992"},"modified":"2013-07-04T13:09:22","modified_gmt":"2013-07-04T11:09:22","slug":"get-supported-server-extensions-imap-pop3-smtp","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/get-supported-server-extensions-imap-pop3-smtp","title":{"rendered":"Get supported server extensions (IMAP, POP3, SMTP)"},"content":{"rendered":"<p>Not every server supports same extensions. This post explains how to get custom extensions supported by the email server in .NET.<\/p>\n<div class=\"well\">\n<ul>\nYou can also read how to: <\/p>\n<li><a href=\"\/blog\/get-supported-authentication-methods-imap-pop3-smtp\">Get supported authentication methods (IMAP, POP3, SMTP)<\/a><\/li>\n<\/ul>\n<\/div>\n<p>Even though protocol commands and responses are different between server types (IMAP, POP3, and SMTP), client API is very similar. Great care is taken to make it almost the same for all email protocols. You can use <em>SupportedExtensions <\/em>on <em>Imap<\/em>, <em>Pop3<\/em> or <em>Smtp<\/em> class to retrieve extensions supported by the server.<\/p>\n<p>There are 3 different classes that represent server extensions for each email protocol: <em>ImapExtension<\/em>, <em>Pop3Extension <\/em>and <em>SmtpExtension<\/em>. Those classes contain static properties with well-know extensions like: <em>ImapExtension.Idle<\/em> or <em>ImapExtension.Sort<\/em> or <em>Pop3Extension.STLS<\/em> etc. <em>SupportedExtensions <\/em> returns a list of them.<\/p>\n<p>You can use <em>SupportedExtensions<\/em> method to retrieve all protocol extensions supported by the server.<\/p>\n<h2>Get supported IMAP server extensions<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing (Imap client = new Imap())\r\n{\r\n    client.ConnectSSL(&quot;imap.example.org&quot;);\r\n    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);\r\n\r\n    Console.WriteLine(&quot;Supported extensions:&quot;);\r\n\r\n    foreach (ImapExtension extension in client.SupportedExtensions())\r\n    {\r\n        Console.WriteLine(extension.Name);\r\n    }\r\n\r\n    Console.WriteLine(&quot;Supports IDLE:&quot;);\r\n\r\n    bool supportsIdle = client.SupportedExtensions()\r\n        .Contains(ImapExtension.Idle);\r\n\r\n    Console.WriteLine(supportsIdle);\r\n\r\n    client.Close();\r\n}\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing client As New Imap()\r\n    client.ConnectSSL(&quot;imap.example.org&quot;)\r\n    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)\r\n\r\n    Console.WriteLine(&quot;Supported extensions:&quot;)\r\n\r\n    For Each extension As ImapExtension In client.SupportedExtensions()\r\n\t    Console.WriteLine(extension.Name)\r\n    Next\r\n\r\n    Console.WriteLine(&quot;Supports IDLE:&quot;)\r\n\r\n    Dim supportsIdle As Boolean = client.SupportedExtensions() _\r\n        .Contains(ImapExtension.Idle)\r\n\r\n    Console.WriteLine(supportsIdle)\r\n\r\n    client.Close()\r\nEnd Using\r\n<\/pre>\n<p>For example Gmail produces following output:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nSupported extensions:\r\nIMAP4rev1\r\nUNSELECT\r\nIDLE\r\nNAMESPACE\r\nQUOTA\r\nID\r\nXLIST\r\nCHILDREN\r\nX-GM-EXT-1\r\nUIDPLUS\r\nCOMPRESS\r\n\r\nSupports IDLE:\r\nTrue\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2010\/04\/capabilities.png\" alt=\"\" title=\"capabilities\" width=\"288\" height=\"154\" class=\"aligncenter size-full wp-image-833\" \/><\/p>\n<p>We take great care for the API to look similar for all protocols (IMAP, POP3, SMTP).<\/p>\n<h2>Get supported POP3 server extensions<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing (Pop3 client = new Pop3())\r\n{\r\n    client.ConnectSSL(&quot;pop3.example.org&quot;);\r\n    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);\r\n\r\n    Console.WriteLine(&quot;Supported extensions:&quot;);\r\n\r\n    foreach (Pop3Extension extension in client.SupportedExtensions())\r\n    {\r\n        Console.WriteLine(extension.Name);\r\n    }\r\n\r\n    Console.WriteLine(&quot;Supports TOP:&quot;);\r\n\r\n    bool supportsTop= client.SupportedExtensions()\r\n        .Contains(Pop3Extension.Top);\r\n\r\n    Console.WriteLine(supportsTop);\r\n\r\n    client.Close();\r\n}\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing client As New Pop3()\r\n    client.ConnectSSL(&quot;pop3.example.org&quot;)\r\n    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)\r\n\r\n    Console.WriteLine(&quot;Supported extensions:&quot;)\r\n\r\n    For Each extension As Pop3Extension In client.SupportedExtensions()\r\n\t    Console.WriteLine(extension.Name)\r\n    Next\r\n\r\n    Console.WriteLine(&quot;Supports TOP:&quot;)\r\n\r\n    Dim supportsTop As Boolean = client.SupportedExtensions() _\r\n        .Contains(Pop3Extension.Top)\r\n\r\n    Console.WriteLine(supportsTop)\r\n\r\n    client.Close()\r\nEnd Using\r\n<\/pre>\n<h2>Get supported SMTP server extensions<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing (Smtpclient = new Smtp())\r\n{\r\n    client.Connect(&quot;smtp.example.org&quot;);\r\n    client.UseBestLogin(&quot;smtp&quot;, &quot;password&quot;);\r\n\r\n    Console.WriteLine(&quot;Supported extensions:&quot;);\r\n\r\n    foreach (SmtpExtension  extension in client.SupportedExtensions())\r\n    {\r\n        Console.WriteLine(extension.Name);\r\n    }\r\n\r\n    Console.WriteLine(&quot;Supports STARTTLS:&quot;);\r\n\r\n    bool supportsStartTLS = client.SupportedExtensions()\r\n        .Contains(SmtpExtension.StartTLS);\r\n\r\n    Console.WriteLine(supportsStartTLS);\r\n\r\n    client.Close();\r\n}\r\n\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing client As New Smtp()\r\n    client.Connect(&quot;smtp.example.org&quot;)\r\n    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;)\r\n\r\n    Console.WriteLine(&quot;Supported extensions:&quot;)\r\n\r\n    For Each extension As SmtpExtension In client.SupportedExtensions()\r\n\t    Console.WriteLine(extension.Name)\r\n    Next\r\n\r\n    Console.WriteLine(&quot;Supports STARTTLS:&quot;)\r\n\r\n    Dim supportsStartTLS As Boolean = client.SupportedExtensions() _\r\n        .Contains(SmtpExtension.StartTLS)\r\n\r\n    Console.WriteLine(supportsStartTLS)\r\n\r\n    client.Close()\r\nEnd Using\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Not every server supports same extensions. This post explains how to get custom extensions supported by the email server in .NET. You can also read how to: Get supported authentication methods (IMAP, POP3, SMTP) Even though protocol commands and responses are different between server types (IMAP, POP3, and SMTP), client API is very similar. Great [&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,42,50,57],"class_list":["post-1992","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-imap","tag-pop3","tag-smtp","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1992"}],"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=1992"}],"version-history":[{"count":5,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1992\/revisions"}],"predecessor-version":[{"id":2777,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1992\/revisions\/2777"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}