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