ImapSearchAsync Method (Boolean, String, String)
async/await version of Search(Boolean, String, String).

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public Task<MessageIndexCollection> SearchAsync(
	bool returnUids,
	string searchCondition,
	string charset
)

Parameters

returnUids
Type: SystemBoolean
If true, search results will be returned as UidCollection; otherwise, as MessageNumberCollection.
searchCondition
Type: SystemString
Search expression in IMAP4 language, or a null reference (Nothing in Visual Basic) to make the method return all messages in the folder.
charset
Type: SystemString
Charset used in searchCondition, or a null reference to use US-ASCII setting.

Return Value

Type: TaskMessageIndexCollection
A task that represents the asynchronous operation. The value of TResult parameter is UidCollection or MessageNumberCollection object if the command succeeded; otherwise, a null reference (Nothing in Visual Basic).
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Examples
This WinForms example gets UIDs of all unseen messages in the inbox. The sample requires button1 control on the form and MailBee.ImapMail namespace imported.
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private async void button1_Click(object sender, EventArgs e)
    {
        Imap imp = new Imap();
        await imp.ConnectAsync("mail.afterlogic.com");
        await imp.LoginAsync("test@afterlogic.com", "secret");
        await imp.SelectFolderAsync("Inbox");
        UidCollection uids = (UidCollection) await imp.SearchAsync(true, "unseen", null);
        await imp.DisconnectAsync();
    }
}
See Also