Pop3BeginExecuteCustomCommand Method |
Note: This API is now obsolete.
Begins an asynchronous request for sending the specified user-defined command to the server and getting the response.
Namespace: MailBee.Pop3MailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax [ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use ExecuteCustomCommandAsync instead.")]
public IAsyncResult BeginExecuteCustomCommand(
string commandString,
bool multiLineResponse,
AsyncCallback callback,
Object state
)
<ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use ExecuteCustomCommandAsync instead.")>
Public Function BeginExecuteCustomCommand (
commandString As String,
multiLineResponse As Boolean,
callback As AsyncCallback,
state As Object
) As IAsyncResult
Parameters
- commandString
- Type: SystemString
User-defined command text (including line terminator). - multiLineResponse
- Type: SystemBoolean
true if the given command returns multi-line response
on success; false if the given command always produces single-line response. - callback
- Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference
(Nothing in Visual Basic) if you do not use callbacks. - state
- Type: SystemObject
An object that contains state information for this request.
You can leave it a null reference (Nothing in Visual Basic).
Return Value
Type:
IAsyncResultAn
IAsyncResult that references the asynchronous user-defined command execution.
Exceptions Remarks Examples Sending a mail message to the POP3 server in WinForms application
(the POP3 server must support XTND XMIT extension). Sending itself is performed in a few stages:
- Send XTND XMIT command
- If the server returned positive response indicating XTND XMIT extension
is supported, send message source data (encoded as multi-line POP3 request)
- If the server returned positive response, the message was accepted for delivery
Callback functions are actively used, and the application message loop never gets blocked
(no waiting for an asynchronous method completion is used). Thus, we do need to care about
dead-locks which would occur if an event was raised while the message loop was blocked
by somewhat like
WaitOne(Int32, Boolean) method call.
This sample's code does not handle any events, but it's safe to use them if needed.
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;
private void XtndXmitCallback(IAsyncResult result)
{
Pop3 pop = (Pop3)result.AsyncState;
try
{
pop.EndExecuteCustomCommand();
}
catch (MailBeePop3NegativeResponseException)
{
MessageBox.Show("XTND XMIT command is not supported. The server responded: " +
pop.GetServerResponse());
pop.Disconnect();
return;
}
MailMessage msg = new MailMessage();
msg.From.Email = "jdoe@mydomain.com";
msg.To.AsString = "kathy@herdomain.com";
msg.Subject = "Meeting request";
msg.BodyPlainText = "Hi, Kathy,\r\nCan we meet tomorrow?\r\n\r\nRegards,\r\nJohn";
string messageSource = System.Text.Encoding.Default.GetString(msg.GetMessageRawData());
messageSource = messageSource.Replace("\r\n.", "\r\n..");
pop.BeginExecuteCustomCommand(messageSource + "\r\n.\r\n",
false, new AsyncCallback(SubmissionCallback), pop);
}
private void SubmissionCallback(IAsyncResult result)
{
Pop3 pop = (Pop3)result.AsyncState;
try
{
pop.EndExecuteCustomCommand();
MessageBox.Show("Message submitted for delivery");
}
catch (MailBeePop3NegativeResponseException)
{
MessageBox.Show("Message was not submitted. The server responded: " +
pop.GetServerResponse());
}
pop.Disconnect();
}
private void Form1_Load(object sender, System.EventArgs e)
{
Pop3 pop = new Pop3();
pop.Connect("pop.mydomain.com");
pop.Login("jdoe", "secret");
pop.BeginExecuteCustomCommand("XTND XMIT\r\n", false,
new AsyncCallback(XtndXmitCallback), pop);
}
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime
Private Sub XtndXmitCallback(ByVal result As IAsyncResult)
Dim pop As New Pop3
pop = result.AsyncState
Try
pop.EndExecuteCustomCommand()
Catch MailBeePop3NegativeResponseException As Exception
MsgBox("XTND XMIT command is not supported. The server responded: " & _
pop.GetServerResponse())
pop.Disconnect()
Return
End Try
Dim msg As New MailMessage
msg.From.Email = "jdoe@mydomain.com"
msg.To.AsString = "kathy@herdomain.com"
msg.Subject = "Meeting request"
msg.BodyPlainText = "Hi, Kathy,\r\nCan we meet tomorrow?\r\n\r\nRegards,\r\nJohn"
Dim messageSource As String = System.Text.Encoding.Default.GetString(msg.GetMessageRawData())
messageSource = messageSource.Replace("\r\n.", "\r\n..")
pop.BeginExecuteCustomCommand(messageSource + "\r\n.\r\n", False, _
New AsyncCallback(AddressOf SubmissionCallback), pop)
End Sub
Private Sub SubmissionCallback(ByVal result As IAsyncResult)
Dim pop As New Pop3
pop = result.AsyncState
Try
pop.EndExecuteCustomCommand()
MsgBox("Message submitted for delivery")
Catch MailBeePop3NegativeResponseException As Exception
MsgBox("Message was not submitted. The server responded: " & _
pop.GetServerResponse())
End Try
pop.Disconnect()
End Sub
Private Sub Form11_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim pop As New Pop3
pop.Connect("pop.mydomain.com")
pop.Login("jdoe", "secret")
pop.BeginExecuteCustomCommand("XTND XMIT\r\n", False, _
New AsyncCallback(AddressOf XtndXmitCallback), pop)
End Sub
See Also