Monday, March 28, 2011

Retrieving Email from GMail using POP3 Programmatically with C#

I'm writing some new Dragonpay code to interface with UCPB's online banking system. I need to retrieve some information via POP3 protocol. POP3 is a very simple protocol using TCP stream over port 110. In fact, I've written code 15 years ago to retrieve email and read it over the phone using text-to-speech synthesis using Dialogic software. But the challenge this time is I need to get the data from Google's GMail.

Unlike regular POP3, GMail's POP3 uses SSL encryption. My limited knowledge on encryption does not extend to SSL encryption. So I did some research. The UNIX fetchmail program can retrieve GMail POP3 email with SSL encryption. But to run code after retrieving the email would require having to program with Linux and procmail. Since I mainly write in C# .NET, that was more trouble than its worth.

I eventually found my answer at Code Project -- http://www.codeproject.com/KB/IP/Pop3MailClient.aspx. Downloaded the code and it worked like a charm.

No comments: