Asterisk lags because of imap connection

Hello!

I’m working for an IT company. I was implementing the imap storage on our Asterisk PBX with UW c-client 2007e. And I ran into a trouble:
When Asterisk connects to Exchange server to Inbox folder it begins to lag.

I’ve figured out why does it happens, because some of our workers have thousands of letters in their inbox, so even execution of command select Inbox takes about 30 sec. It’s a long period. But there is another thing that I’ve noticed. After the first execution of commands like select and search (may be some other commands), all next executions take less than a second. So seems, that after some lags in the beginning PBX must work fine, but it doesn’t happen. Seems that Asterisk if it don’t get response for his imap request for too long just forgets about the request, and begins another operation. The feature with decrease of selecting and searching time doesn’t work in this circumstances - repeated request takes the same amount of time, and lags don’t end.

The problem is that even if Inbox contains about 100 letters lags still appear. May be there is possibility to improve search and other commands. May be efficiency of imap work could be improved by changing the system (host) parameters on which our Exchange server runs.

At this moment this problem is solved by creating separate folder for voicemail. But I’d like to save all mails in one folder.

If it’s imposible than say it clearly. Thanks in advance for your ansvers