ImapSearchAsync Method (Boolean, String, String) |
Namespace: MailBee.ImapMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public Task<MessageIndexCollection> SearchAsync(
bool returnUids,
string searchCondition,
string charset
)
Public Function SearchAsync (
returnUids As Boolean,
searchCondition As String,
charset As String
) As Task(Of MessageIndexCollection)
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:
TaskMessageIndexCollectionA 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 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();
}
}
Public Class Form1
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim imp As New Imap
Await imp.ConnectAsync("mail.afterlogic.com")
Await imp.LoginAsync("test@afterlogic.com", "secret")
Await imp.SelectFolderAsync("Inbox")
Dim uids As UidCollection = CType(Await imp.SearchAsync(True, "unseen", Nothing), UidCollection)
Await imp.DisconnectAsync()
End Sub
End Class
See Also