PowerTCP Mail for .NET
ImapCriterion Enumeration
Example  See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace : ImapCriterion Enumeration




Details the search criterion which modifies the IMAP SEARCH command.

Syntax

Visual Basic (Declaration) 
Public Enum ImapCriterion 
   Inherits System.Enum
Visual Basic (Usage)Copy Code
Dim instance As ImapCriterion
C# 
public enum ImapCriterion : System.Enum 
Managed Extensions for C++ 
__value public enum ImapCriterion : public System.Enum 
C++/CLI 
public enum class ImapCriterion : public System.Enum 

Members

MemberDescription
AllSearch for all messages (no restrictions). No search parameter is required.
AnsweredSearch for all answered messages (messages that have the Answered flag set). No search parameter is required.
BccSearch for messages that contain the specified string in the BCC field of the message envelope.
BeforeSearch for messages with internal date that occurs before the specified date.
BodySearch for messages that contain the specified string in the message body.
CcSearch for messages that contain the specified string in the CC field of the message envelope.
DeletedSearch for deleted messages (messages that have the Deleted flag set). No search parameter is required.
DraftSearch for draft messages (messages that have the Draft flag set). No search parameter is required.
FlaggedSearch for flagged messages (messages that have the Flagged flag set). No search parameter is required.
FromSearch for messages that contain the specified string in the FROM field of the message envelope.
HeaderSearch for messages that contain the specified string in the message header. Note that the format requires that the header field be specified, so the parameter value for this search criterion should be "<header> <value>".
KeywordSearch for messages that have the specified keyword flag set. This allows for searches based on custom flag types.
LargerSearch for messages larger than the specified byte count.
NewSearch for all recent and unseen messages (messages with the Recent flag set but not the Seen flag). No search parameter is required.
NotPerform a logical inversion (NOT operation) on another search criterion. No search parameter is required if this is part of a collection of ImapSearchParameters and another search criterion follows this one; otherwise, a search parameter is required.
NotAnsweredSearch for messages that do not have the Answered flag set. No search parameter is required.
NotDeletedSearch for messages that do not have the Deleted flag set. No search parameter is required.
NotDraftSearch for messages that do not have the Draft flag set. No search parameter is required.
NotFlaggedSearch for messages that do not have the Flagged flag set. No search parameter is required.
NotKeywordSearch for messages that do not have the specified keyword flag set. This allows for searches based on custom flag types.
NotSeenSearch for messages that do not have the Seen flag set. No search parameter is required.
OldSearch for messages that do not have the Recent flag set. No search parameter is required.
OnSearch for messages that have an internal date that exactly matches the value specified (disregarding time).
OrPerform a logical OR operation on the two search criterion that follow this one. This search parameter must be followed by two other search parameters; these will represent the conditions to be ORed.
RecentSearch for recent messages (messages that have the Recent flag set). No search parameter is required.
SeenSearch for seen messages (messages that have the Seen flag set). No search parameter is required.
SentBeforeSearch for messages sent before the specified date.
SentOnSearch for messages sent on the specified date.
SentSinceSearch for messages sent after the specified date.
SinceSearch for messages with internal date that occurs after the specified date.
SmallerSearch for messages smaller than the specified byte count.
SubjectSearch for messages that contain the specified string in the message subject.
TextSearch for messages that contain the specified string in either the header or body of the message.
ToSearch for messages that contain the specified string in the TO field of the message.
UidSearch for messages that match the UID or range of UIDs specified. Ranges of UIDs can be specified using the format "<start>:<end>".

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 ImapCriterion enumeration specifies types of search restrictions when using the Mailbox.Search method. Use this enumeration with the ImapSearchParameter class, to create custom searches of messages on the IMAP server.

Inheritance Hierarchy

System.Object
   System.ValueType
      System.Enum
         Dart.PowerTCP.Mail.ImapCriterion

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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