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
public Task<MessageIndexCollection> SearchAsync(
	bool returnUids,
	string searchCondition,
	string charset


Type: SystemBoolean
If true, search results will be returned as UidCollection; otherwise, as MessageNumberCollection.
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.
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).
MailBeeExceptionAn error occurred and ThrowExceptions is true.
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()

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