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




name
The name of the newly created mailbox.
state
User state information.
Begins to asynchronously add a new mailbox to the server.

Syntax

Visual Basic (Declaration) 
Public Function BeginAdd( _
   ByVal name As String, _
   ByVal state As Object _
) As IAsyncResult
Visual Basic (Usage)Copy Code
Dim instance As MailboxCollection
Dim name As String
Dim state As Object
Dim value As IAsyncResult
 
value = instance.BeginAdd(name, state)
C# 
public IAsyncResult BeginAdd( 
   string name,
   object state
)
Managed Extensions for C++ 
public: IAsyncResult* BeginAdd( 
   string* name,
   Object* state
) 
C++/CLI 
public:
IAsyncResult^ BeginAdd( 
   String^ name,
   Object^ state
) 

Parameters

name
The name of the newly created mailbox.
state
User state information.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.

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.InvalidOperationExceptionBeginXXX method used without providing an EndXXX event handler --or--Attempt to illegally modify a server-side collection.

Example

The following example demonstrates asynchronously creating a new mailbox.
Visual BasicCopy Code
private void AsynchronousMailboxCreateTest()
{
   ' Login to the server.
   Imap1.Login(Server, User, Pass)

   ' Begin to asynchronously create a new mailbox. When
   ' complete, the Imap.EndMailboxAdd event will be raised.
   Imap1.Mailboxes.BeginAdd("MyNewMailbox", Nothing)
}

Private Sub Imap1_EndMailboxAdd(ByVal sender As Object, ByVal e As Dart.PowerTCP.Mail.MailboxEventArgs) Handles Imap1.EndMailboxAdd
   If e.Exception Is Nothing Then
      Debug.WriteLine("New mailbox " + e.Mailbox.Name + " created.")
   Else
      Debug.WriteLine("Exception received: " + e.Exception.Message)
   End If
End Sub
C#Copy Code
private void AsynchronousMailboxCreateTest()
{
   // Login to the server.
   imap1.Login(Server, User, Pass);

   // Begin to asynchronously create a new mailbox. When
   // complete, the Imap.EndMailboxAdd event will be raised.
   imap1.Mailboxes.BeginAdd("MyNewMailbox", null);
}

private void imap1_EndMailboxAdd(object sender, Dart.PowerTCP.Mail.MailboxEventArgs e)
{
   if(e.Exception == null)
      Debug.WriteLine("New mailbox " + e.Mailbox.Name + " created.");
   else
      Debug.WriteLine("Exception received: " + e.Exception.Message);
}

Remarks

The MailboxCollection.BeginAdd method begins to asynchronously create a new mailbox on the server using the specified name by sending the IMAP CREATE command. When complete, the Imap.EndMailboxAdd event is raised. name will be used to create the mailbox "within" the currently selected mailbox by adding name to the parent mailboxes name. If there is no parent of this mailbox, then the new mailbox will be a top-level mailbox.

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.