PowerTCP Mail for .NET
Remove(Mailbox) Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > MailboxCollection Class > Remove Method : Remove(Mailbox) Method




value
The Mailbox object representing the mailbox to remove.
Removes a mailbox from the server.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Remove( _
   ByVal value As Mailbox _
) 
Visual Basic (Usage)Copy Code
Dim instance As MailboxCollection
Dim value As Mailbox
 
instance.Remove(value)
C# 
public void Remove( 
   Mailbox value
)
Managed Extensions for C++ 
public: void Remove( 
   Mailbox* value
) 
C++/CLI 
public:
void Remove( 
   Mailbox^ value
) 

Parameters

value
The Mailbox object representing the mailbox to remove.

Exceptions

ExceptionDescription
Dart.PowerTCP.Mail.ProtocolExceptionBad IMAP protocol response received from server.
System.Net.Sockets.SocketExceptionThe requested address is not valid in its context.
System.InvalidOperationExceptionAttempt to illegally modify a server-side collection.

Example

The following example demonstrates some of the methods of MailboxCollection.
Visual BasicCopy 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();
}

Remarks

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.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.