I wanted to access over IMAP to my gmail account bsed on this example:
http://code.msdn.microsoft.com/windowsdesktop/Simple-IMAP-CLIENT-b249d2e6
When I start to debug the code, I get always an error at the codeline:
tcpc = new System.Net.Sockets.TcpClient("imap.gmail.com", 993);
It gives me the error: "The requested service provider could not be loaded or initialized"
My search on Internet give me as result, that I need to repair the Window Socket. But, when I run directkly the compiled .exe file, then I don't get this error at all. This makes no sense to me.
Does anybody have an idea, whats wrong here?
The code looks like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
namespace IMAP
{
class Program
{
static System.Net.Sockets.TcpClient tcpc = null;
static System.Net.Security.SslStream ssl = null;
static string username, password;
static void Main(string[] args)
{
username = "(username)";
password = "(password)";
SSLAuthenticate = "imap.gmail.com";
try
{
tcpc = new System.Net.Sockets.TcpClient("imap.gmail.com", 993);
ssl = new System.Net.Security.SslStream(tcpc.GetStream());
ssl.AuthenticateAsClient("imap.gmail.com");
...
I am thankful for any help.