import javax.mail.search.*; import static javax.mail.Message.RecipientType; // find any type (To, CC, BCC) static L listMailsTo(Folder f, S address) { ret listMailsTo(f, address, null); } static L listMailsTo(Folder f, S address, RecipientType type) ctex { f.open(f.READ_ONLY); Address a = new InternetAddress(address); SearchTerm term; if (type == null) term = new OrTerm(new SearchTerm[] { new RecipientTerm(RecipientType.TO, a), new RecipientTerm(RecipientType.CC, a), new RecipientTerm(RecipientType.BCC, a) }); else term = new RecipientTerm(type, a); ret asList(f.search(term)); }