MailBee.NET Objects 4.0

Pop3.StartTls Method 

Requests the mail server to start TLS/SSL negotiation and protect the connection with security layer.

public bool StartTls();

Return Value

true if TLS/SSL negotiation succeeded and the connection is now secured with TLS/SSL layer; otherwise, false.

Remarks

As alternative to calling StartTls method, the developer can ask MailBee to start TLS/SSL negotiation automatically by setting SslMode property value to OnConnect or UseStartTls.

Note   Not all mail servers support TLS/SSL functionality.

Exceptions

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

Example

This sample attempts to establish TLS/SSL connection with the POP3 server and displays the number of messages in the inbox on success.

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

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

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

See Also

Pop3 Class | MailBee.Pop3Mail Namespace | SslMode | SslProtocol | BeginStartTls