ImapSocketCreating Event
Occurs when MailBee needs a new socket object for establishing a connection with the IMAP4 server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public event SocketCreatingEventHandler SocketCreating

Value

Type: MailBeeSocketCreatingEventHandler
Remarks
This event is raised just before MailBee will start making the connection (i.e. before SocketConnected event). This lets you specify your own socket object in case if you need some special socket settings. For instance, configure SSL settings for new sockets in UWP apps. If you need this, set NewSocket property to the socket object needed in your event handler.
Note Note
It's possible that this event will fire multiple times in case if the host has multple endpoints assigned. For instance, if the first endpoint was IPv6, the connection could not be made but second endpoint (IPv4) would succeed. On each call of this event handler, your code must supply a new, fresh socket object (otherwise MailBee will create its own). By default, however, MailBee tries IPv4 addresses first (see PreferIPv4Hosts) so this situation is unlikely to happen.
Examples
This code snippet shows how to ignore some SSL certificate errors when making SSL/TLS connections in a UWP app (useful if you connect to local hosts with self-signed certificates, etc).
// Event handler
static void Imp_SocketCreating(object sender, SocketCreatingEventArgs e)
{
    e.NewSocket = new StreamSocket();
    e.NewSocket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);
    e.NewSocket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
    e.NewSocket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
}

// Your async method
...
Imap imp = new Imap();
imp.SocketCreating += new SocketCreatingEventHandler(Imp_SocketCreating);
await imp.ConnectAsync("imap.gmail.com", 993);
...
See Also