Begins an asynchronous request for flagging the specified message for deletion from the server.
An IAsyncResult that references the asynchronous flagging the message for deletion.
This method is an asynchronous version of DeleteMessage.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidStateException | There is already an operation in progress. |
This WinForms sample demonstrates asynchronous flagging the last message for deletion and use of a callback function.
[C#] // To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Pop3Mail; // Put the code below inside your class. // A callback function. private void DeleteMessageCallback(IAsyncResult result) { Pop3 pop = (Pop3)result.AsyncState; pop.EndDeleteMessage(); MessageBox.Show("Last message flagged as deleted"); } // The actual code. private void Form1_Load(object sender, System.EventArgs e) { Pop3 pop = new Pop3(); // Let MailBee process events. pop.RaiseEventsViaMessageLoop = false; pop.Connect("pop.somehost.com"); pop.Login("jdoe", "secret"); // Initiate an asynchronous deletion attempt. pop.BeginDeleteMessage(pop.InboxMessageCount, _ new AsyncCallback(DeleteMessageCallback), pop); // Simulate some lengthy work here... for (int i = 0; i < 100; i++) { // Make a portion of the work. System.Threading.Thread.Sleep(10); // Process events which were raised during execution of the work above. pop.Wait(0); } // If flagging the message is still in progress, wait until it's done. pop.Wait(); // Disconnect from the server. pop.Disconnect(); }
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Pop3Mail ' Put the code below inside your class. ' A callback function. Private Sub DeleteMessageCallback(ByVal result As IAsyncResult) Dim pop As New Pop3 pop = result.AsyncState pop.EndDeleteMessage() MsgBox("Last message flagged as deleted") End Sub ' The actual code. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim pop As New Pop3 ' Let MailBee process events. pop.RaiseEventsViaMessageLoop = False pop.Connect("pop.somehost.com") pop.Login("jdoe", "secret") ' Initiate an asynchronous deletion attempt. pop.BeginDeleteMessage(pop.InboxMessageCount, _ New AsyncCallback(AddressOf DeleteMessageCallback), pop) ' Simulate some lengthy work here... Dim i As Integer For i = 1 To 100 ' Make a portion of the work. System.Threading.Thread.Sleep(10) ' Process events which were raised during execution of the work above. pop.Wait(0) Next ' If flagging the message is still in progress, wait until it's done. pop.Wait() ' Disconnect from the server. pop.Disconnect() End Sub
Pop3 Class | MailBee.Pop3Mail Namespace | DeleteMessage | BeginDeleteMessages