ImapConnect Method (String, Int32)
Connects to an IMAP4 server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public bool Connect(
	string serverName,
	int port
)

Parameters

serverName
Type: SystemString
The name or IP address of the IMAP4 server.
port
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).

Return Value

Type: Boolean
true if a connection attempt succeeded; otherwise, false.
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks
By default, MailBee can autodetect if the mail server you're connecting to requires SSL connection (this works for well-known mail services like gmail.com or live.com). Thus, this method can actually connect to the mail server on port 993 if you specified "imap.gmail.com" as serverName. To disable SSL mode and port autodetection, set AutodetectPortAndSslMode to false.
Examples
This sample connects to the IMAP4 server, logs in the account and selects "Inbox" folder, then downloads the last message entirely, and displays filenames of all attachments.
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.ImapMail;
using MailBee.Mime;

// The actual code (put it into a method of your class).
Imap imp = new Imap();
imp.Connect("mail.domain.com", 143);
imp.Login("jdoe", "secret");
imp.SelectFolder("Inbox");
MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false);
foreach (Attachment attach in msg.Attachments)
{
    Console.WriteLine(attach.Filename);
}
imp.Disconnect();
See Also