The below code is being used to fetch email messages from an Exchange email account. When attempting to return message from an account containing 10 to 20,000 messages the processes continually slows and after roughly 1 hour the process never returns. It should be noted the problem was experienced while bench marking with an overpower Exchange server (46GB of RAM all SS drives) and that was tweaked to force a cache big enough to fit the entire database. The server and the machine were on the same network so latency was not an issue. The maxCount parameter was added to see if there was a sweet spot that might improve response but regardless of it's value the issue remained. Any recommendations for optimization to improve throughput?
protected override MailInfoCollection download()
maxCount = 50;
MailInfoCollection emailList = new MailInfoCollection();
//this query is for returning only the unread
ImapQueryBuilder imapbuilder = new ImapQueryBuilder();
Aspose.Email.MailQuery query = imapbuilder.GetQuery();
ImapMessageInfoCollection messageInfos = _client.ListMessages(query, maxCount);
if (messageInfos.Count > 0)
for (int i = 0; i < messageInfos.Count; i++)
ImapMessageInfo info = messageInfos[i];
MailMessage message = null;
//_client stays connect until all messages are retrieved.
message = _client.FetchMessage(info.SequenceNumber);
catch (Exception e)
Thank you for contacting Aspose support team.
I have tried to reproduce this scenario with my test account but afraid to share that could not succeed due to short number of messages in the account. This issue requires a test account where such large number of messages are present.
Could you please arrange some test account credentials where we can perform these tests? It will help us to analyze the problem and provide assistance as soon as possible.
Thank you for the reply. Although I have the ability to generate unlimited email message internal to my company and any of our test email systems (Exchange, Notes, GroupWise) I do not have the ability to do so for an external facing account such as gmail. It is my belief that even if I was to point the email generation tool at such an account it would certainly be block as spam. I guess I can take from your response that the Aspose MAPI libraries have not been designed, or tested, for such large email counts. Is that correct?
I am not sure about 20,000 messages, but I have certainly tested it with my Exchange Server account that has a total of 11,550 messages in the inbox folder. Since your code sample lists only those which are unread, I made a hundred of these items Unread and tested this scenario at my end using the latest version of Aspose.Email for .NET 4.1.0. The execution results can be seen as attached in this screenshot which shows that it almost took 1 minute to list unread messages and the same amount for time for fetching these unread messages. Could you please share how many Unread items your inbox contains where the test fails? Please try it at your end and let us know your feedback for further assistance.
All 20,000 start off unread as we begin to process.
We need a little time to investigate this issue by setting up an account that contains this much amount of data. Also, the tests will be carried out with another 3rd party library as well to observe the differences and We’ll write back here once we are done with our investigations and appreciate your patience in this regard.