ImapConnect Method (String) |
Connects to an IMAP4 server on the standard IMAP4 port (143).
Namespace: MailBee.ImapMailAssembly: MailBee.NET.45 (in MailBee.NET.45.dll) Version: 10.0.45.502
Syntaxpublic bool Connect(
string serverName
)
Public Function Connect (
serverName As String
) As Boolean
Parameters
- serverName
- Type: SystemString
The name or IP address of the IMAP4 server.
Return Value
Type:
Booleantrue if a connection attempt succeeded; otherwise,
false.
Exceptions
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.
ExamplesThis 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.
using MailBee;
using MailBee.ImapMail;
using MailBee.Mime;
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();
Imports MailBee
Imports MailBee.ImapMail
Imports MailBee.Mime
Dim imp As New Imap
imp.Connect("mail.domain.com")
imp.Login("jdoe", "secret")
imp.SelectFolder("Inbox")
Dim msg As MailMessage = imp.DownloadEntireMessage(imp.MessageCount, False)
msg.Parser.HtmlToPlainMode = HtmlToPlainAutoConvert.IfNoPlain
Console.WriteLine(msg.BodyPlainText)
imp.Disconnect()
See Also