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

Free Support Forum - aspose.com

Exception in client.listMessages(query)

I am copying examples from your site and getting exception. What am I doing wrong?

        ImapClient client = new ImapClient();
        client.setHost(“xxx”);
        client.setPort(143);
        client.setUsername(“test@xxx”);
        client.setPassword(“xxx”);
        client.setSecurityOptions(SecurityOptions.Auto);

        System.out.println(“INBOX---------------------”);

        client.selectFolder(ImapFolderInfo.IN_BOX);
        ImapMessageInfoCollection coll = client.listMessages(5);
        for(ImapMessageInfo msgInfo:coll)
        {
            if (msgInfo.isRead())
                continue;
            System.out.println("Message Subject: " + msgInfo.getSubject());
            System.out.println("From: "+ msgInfo.getSender().getAddress());
            System.out.println(“Sent Date: " + msgInfo.getDate());
            System.out.println(“Mime Message Id: "  + msgInfo.getMessageId());
            System.out.println(””);
        }

        System.out.println(“INBOX22222---------------------”);

        ImapQueryBuilder builder = new ImapQueryBuilder();
        builder.hasNoFlags(ImapMessageFlags.isRead());
        MailQuery query = builder.getQuery();

        ImapMessageInfoCollection messages = client.listMessages(query);

It gives me next output:

INBOX---------------------
Message Subject: test
From: tverhun@xxx
Sent Date: Tue Jan 19 10:01:03 EET 2016
Mime Message Id: CAO5g_7O+9oZYapNujPSf6Eg2ZL0C2M7n7YiiaHtsYCxvSkQDLg@mail.gmail.com

Message Subject: AAA
From: tverhun@xxx
Sent Date: Tue Jan 19 13:30:32 EET 2016
Mime Message Id: CAO5g_7MyQSrVngebzfcaWt8Dx3SFurWeBFE+7PnvmpMwcuGG2Q@mail.gmail.com

INBOX22222---------------------
Exception in thread “main” java.lang.IllegalAccessError: class com.aspose.email.internal.ag.ny cannot access its superclass com.aspose.email.system.exceptions.d
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.aspose.email.internal.ag.dr.a(Unknown Source)
at com.aspose.email.internal.ag.dr.a(Unknown Source)
at com.aspose.email.internal.ag.ex.a(Unknown Source)
at com.aspose.email.internal.ag.gw.b(Unknown Source)
at com.aspose.email.internal.ag.gw.n(Unknown Source)
at com.aspose.email.MailQuery.a(Unknown Source)
at com.aspose.email.pf.a(Unknown Source)
at com.aspose.email.pf.a(Unknown Source)
at com.aspose.email.ImapClient.listMessages(Unknown Source)
at AsposeEmail.main(AsposeEmail.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Hi Taras,


Thank you for posting your inquiry.

We have tested this issue with the latest version of the Aspose.Email API at our end and no such exception is raised. Please try the same with the latest version of Aspose.Email for Java 6.1.0 at your end and let us know your feedback.

I used v.5.1.

Now v.6.1 solved problem.

Hi Taras,


Thank you for the feedback and its nice to hear that your issue is resolved. Should you need any further information, please do not hesitate to contact us.