ImapConnect Method (String)
Connects to an IMAP4 server on the standard IMAP4 port (143).

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
)

Parameters

serverName
Type: SystemString
The name or IP address of the IMAP4 server.

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, selects "Inbox" folder, downloads the last message entirely, and displays its body text. If the message is HTML formatted, plain-text version is displayed.
// 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");
imp.Login("jdoe", "secret");
imp.SelectFolder("Inbox");
MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false);
msg.Parser.HtmlToPlainMode = HtmlToPlainAutoConvert.IfNoPlain;
Console.WriteLine(msg.BodyPlainText);
imp.Disconnect();
See Also