Archived Forum Post

Index of archived forum posts


POP3 Session Management

Jun 29 '12 at 14:49

How i should manage the pop3 sessions? Actually i open the session to download the new emails (headers) and then i do the pop3endsession... Then if i need to fetch an email i start another session, but in some case this create problems: for example hotmail doesn't allow many session in a small amount of time... So i think i should mantain the session opened while the app is active, but i don't know if the session will expire and how i should handle this...


You might leave the session open (don't call Pop3EndSession). If you wish, you could periodically call the mailman.Pop3Noop method to send a no-op message to the POP3 server for the purpose of preventing the connection from becoming idle. Otherwise, you could simply allow the connection to be idle, and then the next time you need to check the server, call Pop3Noop to verify the connection. If Pop3Noop fails, then re-establish the connection explicitly by calling mailman.Pop3BeginSession. Alternatively, given that the Pop3Noop call discovered the disconnection, the next method call needing a connection will automatically re-establish it.