SmtpExecuteCustomCommand Method |
Sends user-defined command to the server and receives the server response to this command.
Namespace: MailBee.SmtpMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool ExecuteCustomCommand(
string commandString
)
Public Function ExecuteCustomCommand (
commandString As String
) As Boolean
Parameters
- commandString
- Type: SystemString
User-defined command text (including line terminator).
Return Value
Type:
Booleantrue if the command was executed successfully; otherwise,
false.
Exceptions Remarks The developer can use
GetServerResponse method to obtain the response
data returned by the server.
Examples This sample connects to the SMTP server, issues HELP command, and displays
the server response to this command. If HELP command is not supported by the server,
MailBee will throw
MailBeeSmtpNegativeResponseException. It's caught in
the sample code, and the proper error message is displayed.
using System;
using MailBee;
using MailBee.SmtpMail;
Smtp mailer = new Smtp();
mailer.SmtpServers.Add("smtp.host.com");
mailer.Connect();
try
{
mailer.ExecuteCustomCommand("HELP\r\n");
Console.WriteLine(mailer.GetServerResponse());
}
catch (MailBeeSmtpNegativeResponseException e)
{
Console.WriteLine(e.Message);
Console.WriteLine("Server response is: " + mailer.GetServerResponse());
}
mailer.Disconnect();
Imports MailBee
Imports MailBee.SmtpMail
Dim mailer As New Smtp
mailer.SmtpServers.Add("smtp.host.com")
mailer.Connect()
Try
mailer.ExecuteCustomCommand("HELP" & vbCrLf)
Console.WriteLine(mailer.GetServerResponse())
Catch e As MailBeeSmtpNegativeResponseException
Console.WriteLine(e.Message)
Console.WriteLine("Server response is: " & mailer.GetServerResponse())
End Try
mailer.Disconnect()
See Also