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

Free Support Forum - aspose.com

ImapClient.SelectFolder hangs

I am running Aspose.Network 5.0.0.0 to monitor messages arriving in an inbox (using IMAP). I do this by calling ImapClient.SelectFolder(folderName) then looking at ImapClient.CurrentFolder.TotalMessageCount. If > 0, there's a message.

It works, but after a while (generally overnight) it hangs on the call to SelectFolder. So I end up restarting the app daily.

I tried removing the call to SelectFolder, but then TotalMessageCount continues to report that there are zero messages even after one has been received.

Is there a way around this?

Thanks

Hi,

Could you please try the latest version of Aspose.Network 5.2 and test if this problem still occurs.

Please make sure that you call the ImapClient.Disconnect() method in the finally block. After how many minutes, do you check for the messages in the Imap server?

Hi Saqib,

The requirement is for new messages to be picked up very promptly so the application checks frequently - typically every minute, but potentially even faster. Because of this, the approach is to keep the connection open and call Disconnect() in the Dispose() method on the calling class.

I tried changing it to keep the connection open, but every hour call Disconnect() then go through the connection process again. This seems to be working (although I haven't done much testing yet).

Does this sound like a reasonable approach?

Thanks

Hi,

Releasing the connection and opening it again after an hour sounds more reasonable. I hope it gets more reliable this way.