Search in sources :

Example 31 with SearchTerm

use of javax.mail.search.SearchTerm in project jodd by oblac.

the class EmailFilterTest method testOr2.

@Test
public void testOr2() {
    EmailFilter emailFilter = filter().or(filter().from("from"), filter().to("to"));
    SearchTerm expected = new OrTerm(new FromStringTerm("from"), new RecipientStringTerm(Message.RecipientType.TO, "to"));
    assertEquals(expected, emailFilter.searchTerm);
}
Also used : OrTerm(javax.mail.search.OrTerm) FromStringTerm(javax.mail.search.FromStringTerm) RecipientStringTerm(javax.mail.search.RecipientStringTerm) SearchTerm(javax.mail.search.SearchTerm) Test(org.junit.Test)

Example 32 with SearchTerm

use of javax.mail.search.SearchTerm in project jodd by oblac.

the class EmailFilter method and.

/**
	 * Defines AND group of filters.
	 */
public EmailFilter and(EmailFilter... emailFilters) {
    SearchTerm[] searchTerms = new SearchTerm[emailFilters.length];
    for (int i = 0; i < emailFilters.length; i++) {
        searchTerms[i] = emailFilters[i].searchTerm;
    }
    concat(new AndTerm(searchTerms));
    return this;
}
Also used : AndTerm(javax.mail.search.AndTerm) SearchTerm(javax.mail.search.SearchTerm)

Example 33 with SearchTerm

use of javax.mail.search.SearchTerm in project jodd by oblac.

the class EmailFilter method subject.

/**
	 * Defines filter for SUBJECT field.
	 */
public EmailFilter subject(String subject) {
    SearchTerm subjectTerm = new SubjectTerm(subject);
    concat(subjectTerm);
    return this;
}
Also used : SearchTerm(javax.mail.search.SearchTerm) SubjectTerm(javax.mail.search.SubjectTerm)

Example 34 with SearchTerm

use of javax.mail.search.SearchTerm in project jodd by oblac.

the class EmailFilter method messageNumber.

/**
	 * Defines message number filter.
	 */
public EmailFilter messageNumber(int messageNumber) {
    SearchTerm msgIdTerm = new MessageNumberTerm(messageNumber);
    concat(msgIdTerm);
    return this;
}
Also used : SearchTerm(javax.mail.search.SearchTerm) MessageNumberTerm(javax.mail.search.MessageNumberTerm)

Example 35 with SearchTerm

use of javax.mail.search.SearchTerm in project jodd by oblac.

the class EmailFilter method to.

/**
	 * Defines filter for TO field.
	 */
public EmailFilter to(String toAddress) {
    SearchTerm toTerm = new RecipientStringTerm(Message.RecipientType.TO, toAddress);
    concat(toTerm);
    return this;
}
Also used : RecipientStringTerm(javax.mail.search.RecipientStringTerm) SearchTerm(javax.mail.search.SearchTerm)

Aggregations

SearchTerm (javax.mail.search.SearchTerm)38 RecipientStringTerm (javax.mail.search.RecipientStringTerm)9 FromStringTerm (javax.mail.search.FromStringTerm)8 Test (org.junit.Test)8 OrTerm (javax.mail.search.OrTerm)6 SubjectTerm (javax.mail.search.SubjectTerm)6 AndTerm (javax.mail.search.AndTerm)5 Message (javax.mail.Message)3 InternetAddress (javax.mail.internet.InternetAddress)3 MimeMessage (javax.mail.internet.MimeMessage)3 FlagTerm (javax.mail.search.FlagTerm)3 HeaderTerm (javax.mail.search.HeaderTerm)3 NotTerm (javax.mail.search.NotTerm)3 IMAPFolder (com.sun.mail.imap.IMAPFolder)2 Date (java.util.Date)2 Flags (javax.mail.Flags)2 MessagingException (javax.mail.MessagingException)2 BodyTerm (javax.mail.search.BodyTerm)2 MessageIDTerm (javax.mail.search.MessageIDTerm)2 ReceivedDateTerm (javax.mail.search.ReceivedDateTerm)2