I wrote a VB.net class around the EAGetmail library. The class has a built in system to check the email at regular intervals in the background. The function that reads and formats the received mail from a POP3 server crashes at least 3 times a day. Under development mode I can continue execution and the DLL will connect and move on. I added a Try-Catch block around it to try to trap and handle it, but that doesn't work. I also added a piece of code that pings the POP3 server to make sure it can be found. If this were a standalone application and running out of the Development environment, this would cause a catastrophic failure. Where this app runs on its own without interaction, this crash is unacceptable. I wondered if the POP3 server was not accepting connections when this occurs. Any help I could get would be greatly appreciated. I have pasted the function below.
       Public Function ReceivePOP3Messages() As EmailMessageStructure()
            Dim Temp() As EmailMessageStructure = Nothing
            Dim Counter As Integer = -1
            Dim ServerOpened As Boolean = False
            Dim Count As Integer = 0
            Dim Content As EmailMessageStructure = Nothing
            Dim Messages() As EAGetMail.MailInfo = Nothing
            Dim EMail As EAGetMail.Mail = Nothing
            Dim Abort As Boolean = False
            Dim Index As Integer = -1
            Dim Found As Boolean = False
            Do
            Application.DoEvents()
            Loop Until (Not cSending)
            cReceiving = True
            Do
                Found = cSimplePingHost(cPOP3MailServer.Server)
                Application.DoEvents()
                If (Not Found) Then
                    cDelay(1000)
                End If
            Loop Until (Found)
            Try
                cPOP3MailClient.Connect(cPOP3MailServer)
            Catch ex As EAGetMail.MailServerException
                RaiseEvent POP3Errors("Mail Initialization Error: " & ex.ErrorMessage)
                Abort = True
            End Try
            If (Not Abort) Then
                ServerOpened = cPOP3MailClient.Connected
                If (ServerOpened) Then
                    Messages = cPOP3MailClient.GetMailInfos
                    Count = Messages.Length
                    If (Count > 0) Then
                        For Each Message In Messages
                            Index += 1
                            EMail = cPOP3MailClient.GetMail(Message)
                            Content = cGetMailMessage(EMail, Index)
                            If (Not IsNothing(Content)) Then
                                Counter += 1
                                ReDim Preserve Temp(Counter)
                                Temp(Counter) = Content
                                'cMarkForDelete(i)
                            End If
                            Content = Nothing
                            If (cPOP3MailServer.Protocol = EAGetMail.ServerProtocol.Imap4) Then
                                cPOP3MailClient.MarkAsRead(Message, True)
                            End If
                            cPOP3MailClient.Delete(Message)
                        Next
                    End If
                    If (cPOP3MailServer.Protocol = EAGetMail.ServerProtocol.Imap4) Then
                        cPOP3MailClient.Logout()
                    End If
                    cPOP3MailClient.Quit()
                End If
            End If
            cReceiving = False
            Return Temp
        End Function