The number of folders in mailbox is limited or system crashed

Hello dear aspose fellows,

I am trying to familiarize myself with how basic functions in the Aspose IMAP client work, so i wrote a small programm, this programm lists the folders in Inbox and give the number of emails in each folder, it works fine at beginning, but when i created more folders in Inbox, the programm just crashed.

here is my code:

public class EmailTest {

ImapClient client;
public static void main(String[] args) {
while(true){
try {
EmailTest emailTest = new EmailTest();
emailTest.test();
System.out.println();
System.out.println();
System.out.println();
System.out.println();
Thread.sleep(5);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

private void test() {
String hostName = "owa.commpany.com";
String userName = "commpany-user";
String passWord = "this is password";

this.client = connectImap(hostName, userName, passWord);
getFolderInfo(client,"Inbox",0);
client.dispose();
client.disconnect();
client = null;
}

private void getFolderInfo(ImapClient client,
String parentFolderName, int level) {
ImapFolderInfoCollection folders = null;
try {
if (parentFolderName == null) {
folders = client.listFolders(true);
} else {
folders = client.listFolders(parentFolderName, true);
}
System.out.println("The number of sub-folders of "
+parentFolderName+" is "+folders.size());
for (ImapFolderInfo imapFolderInfo : folders) {
String folderName = imapFolderInfo.getName();
int messageCount = imapFolderInfo.getTotalMessageCount();

System.out.println();
System.out.println("L"+ level + ": " + folderName
+ "(" + messageCount + ")");
try{
ImapMessageInfoCollection coll
= client.listMessages(folderName, true);

System.out.println("Number of messages in "+ folderName +" is "+coll.size());
}
catch(Exception e){
System.out.println("In the exception ");
}
getFolderInfo(client, folderName, level + 1);
}
}
catch (com.aspose.email.system.exceptions.IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
private ImapClient connectImap(String hostName, String userName, String passWord) {
ImapClient client = new ImapClient();
client.setHost(hostName);
client.setPort(993);
client.setUsername(userName);
client.setPassword(passWord);
client.setSecurityOptions(SecurityOptions.SSLImplicit);
client.setTimeout(300000);
client.setConnectionTimeout(300000);
return client;
}
}


And Exception:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.aspose.email.system.exceptions.ThreadAbortException.()V from class com.aspose.email.internal.af.g
at com.aspose.email.internal.af.g.b(Unknown Source)
at com.aspose.email.ry.o(SourceFile:376)
at com.aspose.email.ry.dispose(SourceFile:259)
at com.aspose.email.sd.dispose(SourceFile:400)
at com.aspose.email.em.y(SourceFile:549)
at com.aspose.email.sv.d(SourceFile:239)
at com.aspose.email.ImapClient.listFolders(SourceFile:2362)
at EmailTest.getFolderInfo(EmailTest.java:51)
at EmailTest.getFolderInfo(EmailTest.java:69)
at EmailTest.test(EmailTest.java:35)
at EmailTest.main(EmailTest.java:18)

I'm using aspose-email-5.6.1.0-jdk16, it is the newest version of aspose email java.



pleace give me some advices, thank you
Hi Jan,

Thank you for contacting Aspose support team.

I have tested this code using my test account credentials and executed the program for long time. I am afraid that no exception is raised and code executed successfully many times. Could you please let us know how many number of folders you added when you got this exception? It will help us to re-produce the issue and provide assistance accordingly.

Hi Muhammad,


Thank you for your response, actually there are not so many folders in my Inbox, but the programm crashed anyway.
As you said, the program executed successfully with your mail account, so i think maybe the problem is on my mail server.

here is the screenshot of folder structure in Inbox.



Hi Jan,


I have tried again by creating folder structure twice in depth than mentioned by you. This code is executed for long time and no exception is raised. In-order to investigate it further, could you please provide us a temporary test account and its credentials on the said server? It will help us to re-produce the scenario and provide assistance accordingly.

Hi Jan.


Thank you for providing test account credentials on live chat. I have tested the code again with these credentials and observed that exception is raised. This issue is logged under id: EMAILJAVA-33537 in our bug reporting system for further investigation by the product team. I shall write here as soon as some feedback is received in this regard.