It looks like connections are not closed (disconnected) when not used anymore.
To know how to do that you should read the documentation of the used
Imap4Client
class.
I would expect that connections are closed in the
Imap4Client
destructor. But even then it would be better to disconnect explicitly.
You can add a disconnect method to the
MailRepository
class and call that when finished using it (when returning from
ReadImap
):
public void Disconnect()
{
if (Client.isConnected())
Client.Disconnect();
}
But note that you can't query data anymore after doing so.