Pop3Connect Method (String, Int32, Boolean) |
Connects to a POP3 server.
Namespace: MailBee.Pop3MailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool Connect(
string serverName,
int port,
bool pipelining
)
Public Function Connect (
serverName As String,
port As Integer,
pipelining As Boolean
) As Boolean
Parameters
- serverName
- Type: SystemString
The name or IP address of the POP3 server. - port
- Type: SystemInt32
The port on which to communicate with the server. The standard POP3 port is 110. For TLS/SSL connections, dedicated port is 995
(however, TLS/SSL connections via regular port are possible too, see SslMode and StartTls topics). - pipelining
- Type: SystemBoolean
Specifies whether to use commands pipelining if it's supported by the server.
Return Value
Type:
Booleantrue if a connection attempt succeeded; otherwise,
false.
Exceptions Remarks If
pipelining is
true and the server supports pipelining,
MailBee will join POP3 commands in batches whenever possible, providing major performance
boost in scenarios when multiple messages are downloaded or deleted at once. The methods
which take advantage of pipelining are:
DownloadMessageHeaders(Int32, Int32, Int32),
DownloadEntireMessages(Int32, Int32),
DeleteMessages(Int32, Int32), and their
asynchronous versions (
BeginDownloadMessages(Int32, Int32, Int32, AsyncCallback, Object),
BeginDeleteMessages(Int32, Int32, AsyncCallback, Object)).
The performance may increase 10+ times if many messages (20 and more) are processed.
Note |
---|
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). To disable SSL mode and port autodetection,
set AutodetectPortAndSslMode to false. |
Examples This sample connects to the POP3 server, downloads headers for the first 5 messages, and
displays them. If the server supports pipelining, all 5 message headers will be downloaded
in a single round-trip to the server.
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;
Pop3 pop = new Pop3();
pop.Connect("mail.domain.com", 110, true);
pop.Login("jdoe", "secret");
MailMessageCollection msgHeaders = pop.DownloadMessageHeaders(1, 5);
foreach (MailMessage msgHeader in msgHeaders)
{
Console.WriteLine("Message #" + msgHeader.IndexOnServer + ":\r\n" + msgHeader.RawHeader);
}
pop.Disconnect();
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Dim pop As Pop3
pop.Connect("mail.domain.com", 110, True)
pop.Login("jdoe", "secret")
Dim msgHeaders As MailMessageCollection
msgHeaders = pop.DownloadMessageHeaders(1, 5)
For Each msgHeader As MailMessage In msgHeaders
Console.WriteLine("Message #" & msgHeader.IndexOnServer & ":\r\n" & msgHeader.RawHeader)
Next
pop.Disconnect()
See Also