Connecting to an IMAP server

ImapX allows you to specify the server, port and encryption in three different ways:
  • Using one of the parameterized constructors when initializing a new ImapClient.
  • Using the client properties.
  • Setting the connection parameters right on calling the Connect method.

Initializing the client

No SSL, default port (143) for connection

var client = new ImapClient("imap.server.com");

SSL, default port (993) for connection

var client = new ImapClient("imap.server.com", true); 

SSL, default port (993) for connection, disable certificate validation

var client = new ImapClient("imap.server.com", true, false); 

No SSL, custom port for connection

var client = new ImapClient("imap.server.com", 888);

SSL, custom port for connection

var client = new ImapClient("imap.server.com", 888, true); 

SSL, custom port for connection, disable certificate validation

var client = new ImapClient("imap.server.com", 888, true, false);

TLS, custom port for connection, disable certificate validation

var client = new ImapClient("imap.server.com", 888, SslProtocols.Tls, false); 

Connecting

if(client.Connect( /* optional, use parameters here */ )) {
     // connection successful
}
else {
     // connection not successful
}

Next

Last edited May 15, 2014 at 8:17 AM by pavel_azanov, version 1