PowerTCP Mail for .NET
ImapCriterion Enumeration
Example Example 




Details criterion for the IMAP SEARCH command.
Syntax
Public Enum ImapCriterion 
   Inherits System.Enum
Dim instance As ImapCriterion
public enum ImapCriterion : System.Enum 
__value public enum ImapCriterion : public System.Enum 
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 an earlier internal date than 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 with an internal date later than the specified date.
SinceSearch for messages sent 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.
Uid Search for messages that match the UID or range of UIDs specified. Ranges of UIDs can be specified using the format "<start>:<end>".
Remarks

This enumeration specifies search restrictions for the Mailbox.Search method. Use this enumeration with the ImapSearchParameter class to create custom searches of an IMAP mailbox.

Example
In this example, the Imap component copies messages that match a specified criteria to another mailbox.
private void getMessages(object state)
{
    //Configure server and account info
    imap1.Session.RemoteEndPoint = new Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session));
    imap1.Session.Username = myUsername;
    imap1.Session.Password = myPassword;

    //Connect and log into the account
    imap1.Connect();
    imap1.Authenticate();

    //Set the selected mailbox to the Inbox
    imap1.SelectedMailbox = imap1.Mailboxes["INBOX"];

    // Construct the search "SEARCH SINCE 1-Jan-2012 NOT FROM JACKSON"
    ImapSearchParameter[] criteria = new ImapSearchParameter[] 
    {
        new ImapSearchParameter(ImapCriterion.Since, "1-Jan-2012"),
        new ImapSearchParameter(ImapCriterion.Not, ""),
        new ImapSearchParameter(ImapCriterion.From, "JACKSON")
    };

    // Perform the search
    ImapMessage[] messages = imap1.SelectedMailbox.Search(criteria);

    //Copy all messages that meet the criteria to the 'Save' mailbox
    foreach (ImapMessage imapMessage in messages)
        imapMessage.CopyTo(imap1.Mailboxes["Save"]);

    //Gracefully logout
    imap1.Close();
}
Private Sub getMessages(ByVal state As Object)
    'Configure server and account info
    imap1.Session.RemoteEndPoint = New Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session))
    imap1.Session.Username = myUsername
    imap1.Session.Password = myPassword

    'Connect and log into the account
    imap1.Connect()
    imap1.Authenticate()

    'Set the selected mailbox to the Inbox
    imap1.SelectedMailbox = imap1.Mailboxes("INBOX")

    ' Construct the search "SEARCH SINCE 1-Jan-2012 NOT FROM JACKSON"
    Dim criteria() As ImapSearchParameter = { New ImapSearchParameter(ImapCriterion.Since, "1-Jan-2012"), New ImapSearchParameter(ImapCriterion.Not, ""), New ImapSearchParameter(ImapCriterion.From, "JACKSON") }

    ' Perform the search
    Dim messages() As ImapMessage = imap1.SelectedMailbox.Search(criteria)

    'Copy all messages that meet the criteria to the 'Save' mailbox
    For Each imapMessage As ImapMessage In messages
        imapMessage.CopyTo(imap1.Mailboxes("Save"))
    Next imapMessage

    'Gracefully logout
    imap1.Close()
End Sub
Inheritance Hierarchy

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

See Also

Reference

Dart.Mail Namespace


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic