This error means that the Mail server has closed the connection. This generally happens when you keep connection open and read email one by one and also do processing i.e. Saving in database, etc.
Instead you should first read emails in some object like DataTable and then do the processing