开发者

OpenPop.Net Exception

I am using OpenPop.net in my application. What this application does is that it downloads mails from a pop3 account saves all the attachments (CSV files) and processes them. This processing takes a lot of time. I am get开发者_如何学编程ting this exception which I am not able to figure out:

Exception message: OpenPop.Pop3.Exceptions.PopServerException: The stream used to retrieve responses from was closed
   at OpenPop.Pop3.Pop3Client.IsOkResponse(String response)
   at OpenPop.Pop3.Pop3Client.SendCommand(String command)
   at OpenPop.Pop3.Pop3Client.DeleteMessage(Int32 messageNumber)

At the end of processing the CSV, the mails are deleted from the pop3 account. I believe this is where this exception is happening.


You are really having two issues here. One is that you are doing a lot of processing while being connected to the POP3 server. When you are idle too long, the server will simply disconnect you to save resources. What you should do, is fetch one email, process the attachments and then reconnect to fetch the next. You could also fetch all the attachments and then process them offline.

Second, I guess you are connecting to a gmail account. Gmail has some weird characteristics. A thread tries to find these characteristics. One of them is that, when you have fetched an email, it will not be available in the next POP3 session with the server. You can connect using a special username, where you append recent: in front of your normal username. This will show you the emails received in the last 30 days, despite of having been showed to an earlier POP3 session.

Hope it helps.


It sounds like something is trying to read a stream that has already been closed. Are you handling the streams at all, or is this done completely internal to the API? If you are handling them at all, there is a chance you are closing the streams (this often happens if someone uses a StreamReader, most people don't realize that closing the StreamReader also closes the underlying stream).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜