ImapBeginSelectFolder Method

Note: This API is now obsolete.

Begins an asynchronous request for selecting a folder in an account on an IMAP4 server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use SelectFolderAsync instead.")]
public IAsyncResult BeginSelectFolder(
	string folderName,
	bool readOnly,
	AsyncCallback callback,
	Object state
)

Parameters

folderName
Type: SystemString
The full name of the folder to be selected.
readOnly
Type: SystemBoolean
Indicates if the folder should be selected in read-only mode.
callback
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
state
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous select folder process.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
This method is an asynchronous version of SelectFolder(String) (if readOnly is false) or ExamineFolder(String) (if readOnly is true).
Examples
This sample demonstrates asynchronous selecting a folder and use of a callback function in a console application.
using System;
using MailBee;
using MailBee.ImapMail;

class Sample
{
    // A callback function.
    private static void SelectFolderCallback(IAsyncResult result)
    {
        Imap imp = (Imap)result.AsyncState;
        imp.EndSelectFolder();
        Console.WriteLine("Overall size of all messages in the inbox is " +
            imp.GetFolderSize() + " bytes");
    }

    // The actual code.
    static void Main(string[] args)
    {
        Imap imp = new Imap();

        imp.Connect("imap4.somehost.com");
        imp.Login("jdoe@somehost.com", "secret");

        // Initiate an asynchronous select folder attempt.
        IAsyncResult ar = imp.BeginSelectFolder("Inbox", false,
            new AsyncCallback(SelectFolderCallback), imp);

        // Simulate some lengthy work here. At the same time,
        // folder selection is executed on another thread.
        System.Threading.Thread.Sleep(3000);

        // If the folder selection attempt is still in progress,
        // then wait until it's finished.
        while (imp.IsBusy) ar.AsyncWaitHandle.WaitOne();

        // Disconnect from the server.
        imp.Disconnect();
    }
}
See Also