How do I read incoming mail using C#

Chris picture Chris · Jan 6, 2011 · Viewed 27.1k times · Source

I am looking for a solution to allow me to read incoming emails. The three methods I can think of to do this at the moment are:

  1. Create an Email Server parsing emails
  2. Hook into an existing exchange server
  3. Hook into outlook that is already set up with an email account

What is the best way to do this? And how does one go about implementing it?

Thanks

Answer

Saul Dolgin picture Saul Dolgin · Jan 6, 2011

If you are already dealing with an Exchange server as the mailbox host I would suggest leveraging that via IMAP (preferred) or POP access. Recently I developed a solution that accesses a specified mailbox via AfterLogic's MailBee.NET IMAP component which I think is worth the recommendation. They have a standard trial version and reasonable pricing. Also if you go this route either POP or IMAP automation is flexible enough to work with almost any mailbox server platform; It doesn't have to be limited to Exchange environments.

There are also free .NET IMAP components out there that may do the job as well. In my limited research I found that the free alternatives didn't quite meet all of my requirements or were not as easy to learn but your situation may differ. For completeness, here is a list of alternative / free IMAP libraries I considered before deciding to spend the money on MailBee:

To address the 2nd part of your question... The implementation in my recent project involved writing a very simple console application that references the MailBee.NET IMAP library. The console application has a standard config file and accepts command line arguments as parameters. We define Windows scheduled tasks to run the console application according to our process needs. I am sure you could do this any number of other ways but this was the simplest approach for our needs.