Integrating POP3 Client Features in a C # Application?

I have a web application that requires the server component to periodically access POP3 mailboxes and receive emails. Then, the service needs to process emails, which will include:

  • Checking email against some business rules (does it contain a valid link in the subject line that the user sent, etc.).
  • Analysis and saving of any attachments to disk
  • Take email and attachment data and create a new item in the database
  • Or update an existing item where the link matches the subject line of the incoming message

What is the best way to approach this? I really don't want to write a POP3 client from scratch, but I need to set up email processing. Ideally, I could connect some component that does access and search for me, returning arrays of attachments, text text, a subject line, etc., Ready for my processing ...

[UPDATE: reviews]

OK, so I spent a lot of time learning (mostly free) .NET POP3 libraries, so I decided to give a brief overview of some of the following and a few others:

  • Pop3.net - for free - works fine, very simple, in terms of functionality. This is pretty much just POP3 commands and some base64 encoding, but it is very simple - perhaps a good introduction.
  • Pop3 Wizard - commercial / some open source - could not build it, skipping the DLL, I would not worry about it
  • C # Mail - free for personal use - works well, comes with a Mime parser and SMTP client, however the comments are in Japanese (not a big deal), and it did not work with SSL β€œout of the box” - I had to change the constructor SslStream after which it did not work.
  • OpenPOP - for free - has not been updated for about 5 years, so the current state of .NET 1.0 does not support SSL, but this is not a problem to solve - I just replaced the existing SslStream stream and it worked. Comes with a Mime parser.

From free libraries I would go to C # Mail or OpenPOP.

I looked at several commercial libraries: Chillkat , Rebex , RemObjects , JMail.net . Based on the characteristics, price and experience of the company, I will probably go to Rebex in the future if my requirements change or I encounter production problems with C # Mail or OpenPOP.

In case someone needs it, this is the SslStream replacement constructor that I used to enable SSL with C # Mail and OpenPOP:

SslStream stream = new SslStream(clientSocket.GetStream(), false, delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors) { return true; }); 
+53
pop3 review
Oct 25 '08 at 13:09
source share
15 answers

I am one of the main developers of OpenPop.NET . I just fell for this review and had to come with some comments regarding the current state of OpenPop.NET, as the review seems deprecated with development.

OpenPop.NET is back in active development. SSL was introduced six months ago. The project had a lot of refactoring and is now much more stable and easy to use. When I took over the project, there were a lot of mistakes in it, and at the moment I do not know them. Many additional functions have been implemented, mainly in the MIME analyzer part. The project is supported by unit tests, and every time an error is detected, a unit test is created to show this error before it is fixed. There is now an accompanying website . There have also been other updates, but I do not want to mention them all.

In addition, the OpenPop.NET license has been changed from LGPL to Public Domain (otherwise, there are no restrictions). I think this is important for commercial users.

+28
Dec 25 '10 at 11:56
source share

I recently implemented an OpenPop project for a project and was pleased with it. He does what he says in tin. (and it's free.)

+7
Oct 25 '08 at 14:57
source share

The constructor of the SslStream class has been modified and loaded. Recommended version does not make sense to use.

+6
Dec 24 '08 at 14:50
source share

C # Mail is available on Codeplex and is pretty easy to use.

+2
Oct 25 '08 at 14:51
source share

You can include Mail.dll.NET mail component in your rating. It supports SSL, Unicode, and multinational email support:

 using(Pop3 pop3 = new Pop3()) { pop3.Connect("mail.host.com"); // Connect to server pop3.Login("user", "password"); // Login foreach(string uid in pop3.GetAll()) { IMail email = new MailBuilder() .CreateFromEml(pop3.GetMessageByUID(uid)); Console.WriteLine(email.Subject); } pop3.Close(true); } 

IMAP protocol is also supported.

Please note that this is a commercial product that I created.

You can download it here: http://www.lesnikowski.com/mail

+2
May 18 '10 at 10:51
source share

New option (since 2014) Xamarin MailKit , available under the MIT license. It parses messages from disk 25 times faster than OpenPOP.NET. It includes IMAP, POP3, and SMTP support and seems to be very fast and reliable.

+2
Aug 21 '14 at 0:20
source share

There are several POP3 client implementations in codeproject.com. I did not appreciate them, but maybe you can find what you need. If not, I can say that POP3 is a fairly simple protocol. You can even read your POP3 block with telnet if you know 4-5 commands.

You just need these commands and maybe some base64 decoding for attachments. What is it.

+1
Oct 25 '08 at 13:19
source share

Jmail.NET . Do not look further. Please note that the free version does not include POP3. You will want to take the standard version (or more). Do not worry, it is not expensive.

+1
Oct 25 '08 at 13:23
source share

Take a look at the POP3 integration in my open source BugTracker.NET application at http://ifdefined.com/bugtrackernet.html . Everything is free and open source. The hardest part, mime parsing, is done on SharpMimeTools BugTracker.NET at http://anmar.eu.org/projects/sharpmimetools/

Important files showing how I use the POP3 and MIME logic are POP3Client.cs and insert_bug.aspx.

+1
Oct. 25 '08 at 17:32
source share

DasBlog uses a good (and free) one capture source package. I used it (but I don’t remember who wrote it, and I'm not on my laptop - Pavel L, I think?). This is not ideal, and it does not do SSL, but it works fine otherwise.

+1
Oct 25 '08 at 17:45
source share

I made my own Mime parser and added it to CodePlex because I continued to work with unhandled exceptions with others when I came up with weird encodings of weird combinations of attachments. The pop3 client implementation is crude, just made for testing purposes, but handles this normally. Part of the Mime parser populates the standard MailMessage object, so you can easily redirect it to it. I can expand / improve it on request, but at the moment it works fine for my needs. Feel free to check it out.

http://www.codeplex.com/mimeParser

+1
Dec 06 '08 at 6:24
source share

Lumisoft is open source and includes a POP client (among other things). It has been for many years, very stable.

+1
Dec 08 '08 at 14:04
source share

If you need SSL to access gmail .. here are some changes to the OpenPOP.net library that provide it with SSL support.

OpenPop.net modified to enable SSL support for access to Gmail

+1
Jul 11 '09 at 21:38
source share

Since I had to automate some email processing. I took OpenPop.net I was looking for a way to forward messages with this library and came across this awesome function: http://hpop.sourceforge.net/documentation/OpenPop~OpenPop.Mime.Message.ToMailMessage.html

To summarize, I chose OpenPop.Net and recommend it!

Regards, In JP

+1
Feb 25 2018-11-21T00:
source share

If you don’t mind paying for a component, we have used chilkat in the past with great success. For a couple of hundred bucks you will get a library filled with complete kindness.

0
Oct 25 '08 at 13:33
source share



All Articles