ImapConnectAsync Method (String, Int32, Socket, EndPoint)

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public Task<bool> ConnectAsync(
	string serverName,
	int port,
	Socket socketToUse,
	EndPoint localEndPoint


Type: SystemString
The name or IP address of the IMAP4 server.
Type: SystemInt32
The port on which to communicate with the server. The standard IMAP4 port is 143. For TLS/SSL connections, dedicated port is 993 (however, TLS/SSL connections via regular port are possible too, see SslMode and StartTls topics).
Type: System.Net.SocketsSocket
Usually, a null reference (Nothing in Visual Basic). You can supply your own socket object here if you wish MailBee to use this object instead of creating a new one (typically, to fine-tune the WinSock subsystem when you need to deal with thousands of connections). This approach is now obsolete. Subscribe to SocketCreating event instead.
Type: System.NetEndPoint
Usually, a null reference. Set it if you need to bind the connection to a certain local IP address/port to fine-tune the performance under heavy loads. If you supply your own socket object (via socketToUse argument), make sure you EITHER bind the local end point to this socket object in your own code (and pass a null reference as localEndPoint value) OR simply pass the local end point as localEndPoint value (not calling socket.Bind in your own code). Also, you can use no local end point at all. Just make sure you're not binding twice: directly in your code and via passing the local end point to this method.

Return Value

Type: TaskBoolean
A task that represents the asynchronous operation. The value of TResult parameter is true if the method succeeds; otherwise, false.
MailBeeExceptionAn error occurred and ThrowExceptions is true.
See Also