<p>I am looking for a method of reading emails using Pop3 in C# 2.0. Currently, I am using code found in <a href="http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx?fid=341657" rel="noreferrer">CodeProject</a>. However, this solution is less than ideal. The biggest problem is that it doesn't support emails written in unicode.</p>

[{'answer_id': 44393, 'author': 'VanOrman', 'author_id': 4550, 'author_profile': 'https://Stackoverflow.com/users/4550', 'pm_score': 7, 'selected': True, 'text': '<p>I\'ve successfully used <a href="http://sourceforge.net/projects/hpop/" rel="noreferrer">OpenPop.NET</a> to access emails via POP3.  </p>\n'}, {'answer_id': 102135, 'author': 'Martin Vobr', 'author_id': 16132, 'author_profile': 'https://Stackoverflow.com/users/16132', 'pm_score': 4, 'selected': False, 'text': '<p>downloading the email via the POP3 protocol is the easy part of the task. The protocol is quite simple and the only hard part could be advanced authentication methods if you don\'t want to send a clear text password over the network (and cannot use the SSL encrypted communication channel). See <a href="http://www.ietf.org/rfc/rfc1939.txt" rel="noreferrer">RFC 1939: Post Office Protocol - Version 3\n</a> and <a href="http://www.ietf.org/rfc/rfc1734.txt" rel="noreferrer">RFC 1734: POP3 AUTHentication command</a> for details.</p>\n\n<p>The hard part comes when you have to parse the received email, which means parsing MIME format in most cases. You can write quick&amp;dirty MIME parser in a few hours or days and it will handle 95+% of all incoming messages. Improving the parser so it can parse almost any email means:</p>\n\n<ul>\n<li>getting email samples sent from the most popular mail clients and  improve the parser in order to fix errors and RFC misinterpretations generated by them.</li>\n<li>Making sure that messages violating RFC for message headers and content will not crash your parser and that you will be able to read every readable or guessable value from the mangled email</li>\n<li>correct handling of internationalization issues (e.g. languages written from righ to left, correct encoding for specific language etc) </li>\n<li>UNICODE</li>\n<li>Attachments and hierarchical message item tree as seen in <a href="http://www.rebex.net/secure-mail.net/sample-mime-explorer.aspx" rel="noreferrer">"Mime torture email sample"</a> </li>\n<li>S/MIME (signed and encrypted emails).</li>\n<li>and so on</li>\n</ul>\n\n<p>Debugging a robust MIME parser takes months of work. I know, because I was watching my friend writing one such parser for the component mentioned below and was writing a few unit tests for it too ;-)</p>\n\n<p>Back to the original question.</p>\n\n<p>Following <a href="http://www.rebex.net/secure-mail.net/tutorial-pop3.aspx#downloading" rel="noreferrer">code taken from our POP3 Tutorial page</a> and links would help you:</p>\n\n<pre><code>// \n// create client, connect and log in \nPop3 client = new Pop3();\nclient.Connect("pop3.example.org");\nclient.Login("username", "password");\n\n// get message list \nPop3MessageCollection list = client.GetMessageList();\n\nif (list.Count == 0)\n{\n    Console.WriteLine("There are no messages in the mailbox.");\n}\nelse \n{\n    // download the first message \n    MailMessage message = client.GetMailMessage(list[0].SequenceNumber);\n    ...\n}\n\nclient.Disconnect();\n</code></pre>\n\n<ul>\n<li><a href="http://blog.rebex.net/news/archive/2007/05/14/howto-download-emails-from-gmail-account-in-csharp.aspx" rel="noreferrer">HOWTO: Download emails from a GMail account in C#</a> (blogpost)</li>\n<li><a href="http://www.rebex.net/mail.net/" rel="noreferrer">Rebex Mail for .NET (POP3/IMAP client component for .NET)</a></li>\n<li><a href="http://www.rebex.net/secure-mail.net/" rel="noreferrer">Rebex Secure Mail for .NET (POP3/IMAP client component for .NET - SSL enabled)</a> </li>\n</ul>\n'}, {'answer_id': 102224, 'author': 'stephenbayer', 'author_id': 18893, 'author_profile': 'https://Stackoverflow.com/users/18893', 'pm_score': 2, 'selected': False, 'text': "<p>call me old fashion but why use a 3rd party library for a simple protocol.  I've implemented POP3 readers in web based ASP.NET application with System.Net.Sockets.TCPClient and System.Net.Security.SslStream for the encryption and authentication.  As far as protocols go, once you open up communication with the POP3 server, there are only a handful of commands that you have to deal with.  It is a very easy protocol to work with.  </p>\n"}, {'answer_id': 118662, 'author': 'Corey Trager', 'author_id': 9328, 'author_profile': 'https://Stackoverflow.com/users/9328', 'pm_score': 3, 'selected': False, 'text': '<p>My open source application <a href="http://ifdefined.com/bugtrackernet.html" rel="nofollow noreferrer">BugTracker.NET</a> includes a POP3 client that can parse MIME.   Both the POP3 code and the MIME code are from other authors, but you can see how it all fits together in my app.</p>\n\n<p>For the MIME parsing, I use <a href="http://anmar.eu.org/projects/sharpmimetools/" rel="nofollow noreferrer">http://anmar.eu.org/projects/sharpmimetools/</a>.  </p>\n\n<p>See the file POP3Main.cs, POP3Client.cs, and insert_bug.aspx</p>\n'}, {'answer_id': 669567, 'author': 'Pawel Lesnikowski', 'author_id': 80894, 'author_profile': 'https://Stackoverflow.com/users/80894', 'pm_score': 3, 'selected': False, 'text': '<p>You can also try <a href="https://www.limilabs.com/mail" rel="nofollow noreferrer">Mail.dll mail component</a>, it has SSL support, unicode, and multi-national email support:</p>\n\n<pre><code>using(Pop3 pop3 = new Pop3())\n{\n    pop3.Connect("mail.host.com");           // Connect to server and login\n    pop3.Login("user", "password");\n\n    foreach(string uid in pop3.GetAll())\n    {\n        IMail email = new MailBuilder()\n            .CreateFromEml(pop3.GetMessageByUID(uid));\n          Console.WriteLine( email.Subject );\n    }\n    pop3.Close(false);      \n}\n</code></pre>\n\n<p>You can download it here at <a href="https://www.limilabs.com/mail" rel="nofollow noreferrer">https://www.limilabs.com/mail</a></p>\n\n<p>Please note that this is a commercial product I\'ve created.</p>\n'}, {'answer_id': 1240999, 'author': 'Richard Beier', 'author_id': 79820, 'author_profile': 'https://Stackoverflow.com/users/79820', 'pm_score': 2, 'selected': False, 'text': '<p>I wouldn\'t recommend OpenPOP. I just spent a few hours debugging an issue - OpenPOP\'s POPClient.GetMessage() was mysteriously returning null. I debugged this and found it was a string index bug - see the patch I submitted here: <a href="http://sourceforge.net/tracker/?func=detail&amp;aid=2833334&amp;group_id=92166&amp;atid=599778" rel="nofollow noreferrer">http://sourceforge.net/tracker/?func=detail&amp;aid=2833334&amp;group_id=92166&amp;atid=599778</a>. It was difficult to find the cause since there are empty catch{} blocks that swallow exceptions.</p>\n\n<p>Also, the project is mostly dormant... the last release was in 2004.</p>\n\n<p>For now we\'re still using OpenPOP, but I\'ll take a look at some of the other projects people have recommended here.</p>\n'}, {'answer_id': 11553097, 'author': 'Higty', 'author_id': 48905, 'author_profile': 'https://Stackoverflow.com/users/48905', 'pm_score': 2, 'selected': False, 'text': '<p>HigLabo.Mail is easy to use. Here is a sample usage:</p>\n\n<pre><code>using (Pop3Client cl = new Pop3Client()) \n{ \n    cl.UserName = "MyUserName"; \n    cl.Password = "MyPassword"; \n    cl.ServerName = "MyServer"; \n    cl.AuthenticateMode = Pop3AuthenticateMode.Pop; \n    cl.Ssl = false; \n    cl.Authenticate(); \n    ///Get first mail of my mailbox \n    Pop3Message mg = cl.GetMessage(1); \n    String MyText = mg.BodyText; \n    ///If the message have one attachment \n    Pop3Content ct = mg.Contents[0];         \n    ///you can save it to local disk \n    ct.DecodeData("your file path"); \n} \n</code></pre>\n\n<p>you can get it from <a href="https://github.com/higty/higlabo" rel="nofollow noreferrer">https://github.com/higty/higlabo</a> or Nuget [HigLabo]</p>\n'}, {'answer_id': 13145186, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>I just tried SMTPop and it worked.</p>\n\n<ol>\n<li>I downloaded <a href="http://sourceforge.net/projects/dotnetctrlext/files/smtpop.net/SmtPop.Net%20V%200.5a/smtpop_bin_0.5.1.33667.zip/download" rel="nofollow">this</a>. </li>\n<li>Added <code>smtpop.dll</code> reference to my C# .NET project</li>\n</ol>\n\n<p>Wrote the following code:</p>\n\n<pre><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;    \nusing SmtPop;\n\nnamespace SMT_POP3 {\n\n    class Program {\n        static void Main(string[] args) {\n            SmtPop.POP3Client pop = new SmtPop.POP3Client();\n            pop.Open("&lt;hostURL&gt;", 110, "&lt;username&gt;", "&lt;password&gt;");\n\n            // Get message list from POP server\n            SmtPop.POPMessageId[] messages = pop.GetMailList();\n            if (messages != null) {\n\n                // Walk attachment list\n                foreach(SmtPop.POPMessageId id in messages) {\n                    SmtPop.POPReader reader= pop.GetMailReader(id);\n                    SmtPop.MimeMessage msg = new SmtPop.MimeMessage();\n\n                    // Read message\n                    msg.Read(reader);\n                    if (msg.AddressFrom != null) {\n                        String from= msg.AddressFrom[0].Name;\n                        Console.WriteLine("from: " + from);\n                    }\n                    if (msg.Subject != null) {\n                        String subject = msg.Subject;\n                        Console.WriteLine("subject: "+ subject);\n                    }\n                    if (msg.Body != null) {\n                        String body = msg.Body;\n                        Console.WriteLine("body: " + body);\n                    }\n                    if (msg.Attachments != null &amp;&amp; false) {\n                        // Do something with first attachment\n                        SmtPop.MimeAttachment attach = msg.Attachments[0];\n\n                        if (attach.Filename == "data") {\n                           // Read data from attachment\n                           Byte[] b = Convert.FromBase64String(attach.Body);\n                           System.IO.MemoryStream mem = new System.IO.MemoryStream(b, false);\n\n                           //BinaryFormatter f = new BinaryFormatter();\n                           // DataClass data= (DataClass)f.Deserialize(mem); \n                           mem.Close();\n                        }                     \n\n                        // Delete message\n                        // pop.Dele(id.Id);\n                    }\n               }\n           }    \n           pop.Quit();\n        }\n    }\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/44383', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/889/']