MailBee.NET Objects 3.1

Imap.ExecuteCustomCommand Method 

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

public bool ExecuteCustomCommand(
   string command,
   string commandID
);

Parameters

command
User-defined command text (without line terminator).
commandID
The ID (tag in IMAP4 terms) which will be prepended to the command text, or an empty string to let MailBee autogenerate the ID value, or a null reference (Nothing in Visual Basic) to send command without ID.

Return Value

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

Remarks

To use this method, the developer should have some knowledge of the IMAP4 protocol.

If commandID is non-empty string and not a null reference, MailBee will send the following request to the server (in C# terms): commandID + " " + command + "\r\n".

If commandID is "" (Empty), the entire request would be "MBNxxxxxxxx" + " " + command + "\r\n" where "xxxxxxxx" is an ordinal number of the issued command since the moment of establishing connection with the server.

If commandID is a null reference, the entire request would be command + "\r\n" (untagged request, also called "command continuation request").

To analyze results of user-defined commands, the developer can use GetServerResponse and GetServerResponses methods.

To check if the server supports the particular extension/capability, the developer can use GetExtension method passing the name of the capability.

Exceptions

Exception TypeCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.

Example

This sample connects to the IMAP4 server, logs in the mail account, and sends IDLE and DONE commands (the server must support IDLE extension).

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

// The actual code (put it into a method of your class)
Imap imp = new Imap();
imp.Connect("imap.company.com");
imp.Login("jdoe", "secret");
imp.ExecuteCustomCommand("IDLE", string.Empty);
imp.ExecuteCustomCommand("DONE", null);
imp.Disconnect();
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code
Imports MailBee
Imports MailBee.ImapMail

' The actual code (put it into a method of your class)
Dim imp As New Imap
imp.Connect("imap.company.com")
imp.Login("jdoe", "secret")
imp.ExecuteCustomCommand("IDLE", String.Empty)
imp.ExecuteCustomCommand("DONE", Nothing)
imp.Disconnect()

See Also

Imap Class | MailBee.ImapMail Namespace