Saturday, July 11, 2009

C# POP3 Library with SSL for Gmail

So I ended up searching for hours trying to find a free C# library to do POP3 access to a SSL server like gmail. In our company we use Google Apps and we like gmail's mail server, it would be nice to be able to have programmatical access to these mail accounts. How does this not exist?

So this solution takes OpenPop.net Open source library and makes some very small tweaks so it has Ssl support.

Here is the important simple code snippet.
Stream actualstream = clientSocket.GetStream();

if (useSSL) {
System.Net.Security.SslStream sslstream = new SslStream(clientSocket.GetStream());
sslstream.AuthenticateAsClient(strHost);
actualstream = sslstream;
}


Attached here is the re zip of the source code with the change to the library and also a tweak to the sample app with a checkbox to include SSL support.

OpenPOP with SSL Source Download

OpenPOP with SSL Binaries Download

Enjoy!