| Visual Basic (Declaration) | |
|---|---|
Public Function BeginRemove( _ ByVal value As Mailbox, _ ByVal state As Object _ ) As IAsyncResult | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As MailboxCollection Dim value As Mailbox Dim state As Object Dim value As IAsyncResult value = instance.BeginRemove(value, state) | |
| C# | |
|---|---|
public IAsyncResult BeginRemove( Mailbox value, object state ) | |
| Managed Extensions for C++ | |
|---|---|
public: IAsyncResult* BeginRemove( Mailbox* value, Object* state ) | |
| C++/CLI | |
|---|---|
public: IAsyncResult^ BeginRemove( Mailbox^ value, Object^ state ) | |
Parameters
- value
- The Mailbox object representing the mailbox to remove.
- state
- User state information.
Return Value
An IAsyncResult that represents the asynchronous operation, which could still be pending.| Exception | Description |
|---|---|
| Dart.PowerTCP.Mail.ProtocolException | Bad IMAP protocol response received from server. |
| System.Net.Sockets.SocketException | The requested address is not valid in its context. |
| System.InvalidOperationException | BeginXXX method used without providing an EndXXX event handler --or--Attempt to illegally modify a server-side collection. |
The following example demonstrates some of the methods of MailboxCollection.
| Visual Basic | Copy Code |
|---|---|
Private Sub MailboxCollectionDemo() ' Login Imap1.Login(Server, User, Pass) ' Create a test mailbox Imap1.Mailboxes.Add("MyNewMailbox") ' Get the name into a short variable name for less typing Dim Box As New Mailbox = imap1.Mailboxes("MyNewMailbox") ' Create a message from a message stored on file. Dim Msg as new MessageStream(New FileStream("C:\mymsg.txt", FileMode.Open)) ' Add a new message with flags and an internal date Dim InternalDate As New System.DateTime(2000, 1, 1) ImapMessage ImapMsg = Box.Messages.Add(Msg, ImapFlags.Flagged, internalDate); ' Remove the mailbox Imap1.Mailboxes.Remove(box) ' Logout imap1.Logout() End Sub | |
| C# | Copy Code |
|---|---|
private void MailboxCollectionDemo() { // Login imap1.Login(Server, User, Pass); // Create a test mailbox imap1.Mailboxes.Add("MyNewMailbox"); // Get the name into a short variable name for less typing Mailbox box = imap1.Mailboxes["MyNewMailbox"]; // Create a message from a message stored on file. MessageStream msg = new MessageStream(new FileStream("C:\\mymsg.txt", FileMode.Open)); // Add a new message with flags and an internal date System.DateTime internalDate = new System.DateTime(2000, 1, 1); ImapMessage imapMsg = box.Messages.Add(msg, ImapFlags.Flagged, internalDate); // Remove the mailbox imap1.Mailboxes.Remove(box); // Logout imap1.Logout(); } | |
The MailboxCollection.BeginRemove method begins to asynchronously remove the mailbox which is equal to value from the server by sending the IMAP DELETE command. Upon completion, the Imap.EndMailboxRemove event is raised.
After calling this method, the MailboxCollection will be automatically updated to reflect the current state of the collection. There is no need to explicitly call MailboxCollection.Refresh.
Target Platforms: Microsoft .NET Framework 2.0