MailBee.NET Objects 3.1

Pop3.ExecuteCustomCommand Method 

Sends user-defined command to the server and receives the server response to this command.

public bool ExecuteCustomCommand(
   string commandString,
   bool multiLineResponse
);

Parameters

commandString
User-defined command text (including line terminator).
multiLineResponse
true if the given command returns multi-line response on success; false if the given command always produces single-line response.

Return Value

true if the command was executed successfully; otherwise, false.

Remarks

The developer can use GetServerResponse method to obtain the response data returned by the server.

Exceptions

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

Example

This sample connects to the POP3 server, issues HELP command, and displays the server response to this command. If HELP command is not supported by the server, MailBee will throw MailBeePop3NegativeResponseException. It's caught in the sample code, and the proper error message is displayed.

[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");
try
{
    // Send HELP command (it produces a single-line response).
    pop.ExecuteCustomCommand("HELP\r\n", false);
    Console.WriteLine(pop.GetServerResponse());
}
catch (MailBeePop3NegativeResponseException e)
{
    // The given POP3 server does not support HELP command.
    Console.WriteLine(e.Message);
    Console.WriteLine("Server response is: " + pop.GetServerResponse());
}
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")
Try
    ' Send HELP command (it produces a single-line response).
    pop.ExecuteCustomCommand("HELP" & vbCrLf, False)
Catch e As MailBeePop3NegativeResponseException
    ' The given POP3 server does not support HELP command.
    Console.WriteLine(e.Message)
    Console.WriteLine("Server response is: " & pop.GetServerResponse())
End Try
pop.Disconnect()

See Also

Pop3 Class | MailBee.Pop3Mail Namespace