We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Can Not Filter Specific Sender from Server Using IMAP Client

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 {

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);



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)

Thank you for posting the query. Unfortunately, I cannot use your code snippet to investigate this case because it contains unknown classes and variables. Please share a comprehensive code example or a simple standalone project.

Thank you for your help. I have change the code. Plese test it again.

1 Like

Thank you for the updated code example. I logged the issue with ID EMAILJAVA-34944 in our tracking system. Our development team will investigate this case. We will inform you of any progress.

Our development team investigated the issue. It seems to be your server does not support UTF8 encoding for IMAP protocol. This feature is not required in RFC 3501. You can check it by enabling IMAP activity logging as shown below:


In CAPABILITY data, you will not see “UTF8=ACCEPT” string.

But you can use ImapQueryBuilder instance without specifying encoding like this:

ImapQueryBuilder builder = new ImapQueryBuilder(/*StandardCharsets.UTF_8*/);

Another way is to use EWSClient class.

API Reference: ImapQueryBuilder Class, EWSClient Class