MailBee.NET Objects 4.0

Pop3.Connect Method (String)

Connects to a POP3 server on the standard POP3 port (110).

public bool Connect(
   string serverName
);

Parameters

serverName
The name or IP address of the POP3 server.

Return Value

true if a connection attempt succeeded; otherwise, false.

Remarks

If Pipelining is true and the server supports pipelining, MailBee will use it and join POP3 commands in batches whenever possible (see Connect overload for more information).

Exceptions

Exception Type Condition
MailBeeException An error occurred and ThrowExceptions is true.

Example

This sample connects to the POP3 server, downloads the last message entirely, and displays its body text. If the message is HTML formatted, plain-text version is displayed.

[C#]
// To use the code below, import MailBee namespaces at the top of your code
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

// The actual code (put it into a method of your class)
Pop3 pop = new Pop3();
pop.Connect("mail.domain.com");
pop.Login("jdoe", "secret");
MailMessage msg = pop.DownloadEntireMessage(pop.InboxMessageCount);
Console.WriteLine(msg.BodyPlainText);
pop.Disconnect();
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

' The actual code (put it into a method of your class)
Dim pop As New Pop3
pop.Connect("mail.domain.com")
pop.Login("jdoe", "secret")
Dim msg As MailMessage
msg = pop.DownloadEntireMessage(pop.InboxMessageCount)
Console.WriteLine(msg.BodyPlainText)
pop.Disconnect()

See Also

Pop3 Class | MailBee.Pop3Mail Namespace | Pop3.Connect Overload List