PowerTCP Mail for .NET
ImapSearchParameter Class
Members  Example  See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace : ImapSearchParameter Class




Represents a search parameter used with the MailBox.Search method.

Object Model

ImapSearchParameter Class

Syntax

Visual Basic (Declaration) 
Public Class ImapSearchParameter 
Visual Basic (Usage)Copy Code
Dim instance As ImapSearchParameter
C# 
public class ImapSearchParameter 
Managed Extensions for C++ 
public __gc class ImapSearchParameter 
C++/CLI 
public ref class ImapSearchParameter 

Example

The following example demonstrates using the Mailbox.Search method. This example constructs the search "SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'"
Visual BasicCopy Code
' Login
Imap1.Login(Server, User, Pass)

' Construct the search "SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'"
Dim Criteria As New ArrayList()
Criteria.Add(New ImapSearchParameter(ImapCriterion.Flagged, ""))
Criteria.Add(New ImapSearchParameter(ImapCriterion.Since, "1-Feb-1994"))
Criteria.Add(New ImapSearchParameter(ImapCriterion.Not, ""))
Criteria.Add(New ImapSearchParameter(ImapCriterion.From, "Smith"))

' Alternatively, ImapSearchParameter objects can be created like so
' Dim Param As New ImapSearchParameter()
' Param.Criterion = ImapCriterion.Flagged
' Param.Paramter = ""
' Criteria.Add(Param)

' Perform the search. This will occur on the default box INBOX.
Dim Messages() As ImapMessage = Imap1.CurrentMailbox.Search(Criteria)

' Display
Debug.WriteLine("The following message IDs meet the specified criteria")
Dim Message as ImapMessage
For Each Message in Messages
   Debug.WriteLine(Message.Id)
C#Copy Code
// Login
imap1.Login(Server, User, Pass);

// Construct the search "SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM 'Smith'"
ArrayList criteria = new ArrayList();
criteria.Add(new ImapSearchParameter(ImapCriterion.Flagged, ""));
criteria.Add(new ImapSearchParameter(ImapCriterion.Since, "1-Feb-1994"));
criteria.Add(new ImapSearchParameter(ImapCriterion.Not, ""));
criteria.Add(new ImapSearchParameter(ImapCriterion.From, "Smith"));

/*
/ Alternatively, ImapSearchParameter objects can be created like so
/ ImapSearchParameter param = new ImapSearchParameter();
/ param.Criterion = ImapCriterion.Flagged;
/ param.Paramter = "";
/ criteria.Add(param);
*/

// Perform the search. This will occur on the default box INBOX.
ImapMessage[] messages = imap1.CurrentMailbox.Search(criteria);

// Display
Debug.WriteLine("The following message IDs meet the specified criteria");
foreach(ImapMessage message in messages)
   Debug.WriteLine(message.Id);

Remarks

The Mailbox.Search method sends the "SEARCH" command to the server along with all of the search restrictions specified ImapSearchParameter. Proper use involves creating an object which implements ICollection, adding several ImapSearchParameters to this object, and passing this object into the Mailbox.Search method. Multiple values are combined with a logical AND. Other logical combinations can be represented using the ImapCriterion values ImapCriterion.Not and ImapCriterion.Or.

Inheritance Hierarchy

System.Object
   Dart.PowerTCP.Mail.ImapSearchParameter

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.