PowerTCP Mail for .NET
ImapSearchParameter Constructor(ImapCriterion,String)
Example 




An ImapCriterion value representing the search criterion.
A string value which modifies criterion.
Creates a new instance of ImapSearchParameter.
Syntax
Public Function New( _
   ByVal criterion As ImapCriterion, _
   ByVal parameter As String _
)
Dim criterion As ImapCriterion
Dim parameter As String
 
Dim instance As New ImapSearchParameter(criterion, parameter)
public ImapSearchParameter( 
   ImapCriterion criterion,
   string parameter
)
public: ImapSearchParameter( 
   ImapCriterion criterion,
   string* parameter
)
public:
ImapSearchParameter( 
   ImapCriterion criterion,
   String^ parameter
)

Parameters

criterion
An ImapCriterion value representing the search criterion.
parameter
A string value which modifies criterion.
Remarks

Creates a new instance of ImapSearchParameter, setting ImapSearchParameter.Criterion to criterion and ImapSearchParameter.Parameter to parameter.

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
See Also

Reference

ImapSearchParameter Class
ImapSearchParameter Members
Overload List


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