use the code to filter Specific Sender:
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import org.junit.Test;
import com.aspose.email.DateComparisonType;
import com.aspose.email.ImapClient;
import com.aspose.email.ImapMessageInfoCollection;
import com.aspose.email.ImapQueryBuilder;
import com.aspose.email.MailQuery;
public class TestEmailFilling {
@Test
public void listMsgInfoByFilter() {
ImapQueryBuilder builder = new ImapQueryBuilder(StandardCharsets.UTF_8);
// date range
Calendar queryDate = Calendar.getInstance();
builder.getInternalDate().since(queryDate.getTime(), DateComparisonType.ByDate);
builder.getInternalDate().beforeOrEqual(queryDate.getTime(), DateComparisonType.ByDate);
// Specific Sender
builder.getFrom().contains("test@hotmail.com", Boolean.TRUE);
MailQuery query = builder.getQuery();
ImapMessageInfoCollection imapMessageInfos = new ImapMessageInfoCollection();
//email config
ImapClient client = new ImapClient("host", port, "username",
"password", securityOptions);
client.selectFolder("Inbox");
imapMessageInfos.addRange(client.listMessages(query));
System.out.print("imapMessageInfos.size:"+imapMessageInfos.size());
}
}
error message:
AE_1_1_0009 NO [BADCHARSET (US-ASCII)] The specified charset is not supported.
com.aspose.email.ImapException: AE_1_1_0009 NO [BADCHARSET (US-ASCII)] The specified charset is not supported.
at com.aspose.email.zem.a(SourceFile:113)
at com.aspose.email.zem.f(SourceFile:96)
at com.aspose.email.zbac.f(SourceFile:97)
at com.aspose.email.zaeh.b(SourceFile:264)
at com.aspose.email.zeg.a(SourceFile:340)
at com.aspose.email.zbft.a(SourceFile:193)
at com.aspose.email.internal.ah.zd.a(SourceFile:65)
at com.aspose.email.internal.ah.ze.run(SourceFile:117)
at java.base/java.lang.Thread.run(Thread.java:834)