| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As MailboxCollection Dim value As Mailbox instance.Remove(value) | |
Parameters
- value
- The Mailbox object representing the mailbox to remove.
| 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 | 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.Remove method removes the mailbox which is equal to value from the server by sending the IMAP DELETE command.
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