/// <summary>
        /// use the pop client to get the latest message 
        /// </summary>
        /// <returns></returns>
        private bool GetLastestUpload_POP()
        {
            //return true;
            try
            {
                using (Pop3Client client = new Pop3Client())
                {

                    //string hostname = "pop.gmail.com";
                    //int port = 995;
                    //bool useSsl = true;
                    //string username = "******";
                    //string password = "******";

                    // Connect to the server

                    int portNo = 0;

                    if (int.TryParse(_popPort, out portNo))
                    {
                        client.Connect(_popHost, portNo, true);

                        // Authenticate ourselves towards the server
                        client.Authenticate(_icmsEmailAddress, _smtpPassword);

                        string fileName = string.Empty;
                        // We know the message contains an attachment with the name "useful.pdf".
                        // We want to save this to a file with the same name
                        //for (int i = client.GetMessageCount(); i == 0; i--)
                        //{
                        int latestMessage = client.GetMessageCount();
                        Message message = client.GetMessage(latestMessage);
                        MMDAutomation.Messageing.MessageLog msgLog = new MessageLog(message.Headers.MessageId, message.Headers.DateSent, _sqlConnectionString);
                        if (message.Headers.Subject.Contains(_emailSubject))
                        {
                            if (!msgLog.CheckMessageId())
                            {

                                //message not found -- process file
                                foreach (MessagePart attachment in message.FindAllAttachments())
                                {
                                    fileName = attachment.FileName;
                                    if (fileName.Split('.')[1].Equals("xlsx")) //attachment.FileName.Equals(@"WADALAOR.xlsx"))
                                    {
                                        // Save the raw bytes to a file
                                        //string fileLocation = @"C:\Users\Marnee Dearman\Documents\SK Auto\ICMS Excel Downloads\";
                                        _attachment += fileName.Replace(" ", "");
                                        System.IO.File.WriteAllBytes(_attachment, attachment.Body);
                                        LogUpload("File downloaded at " + DateTime.Now);
                                    }
                                }

                                msgLog.LogMessageId();
                            }
                        }
                        //client.DeleteMessage(latestMessage);

                    }
                    //client.Dispose();
                    //}
                    return true;
                }
            }
            catch (Exception ex)
            {
                AutoUploadLog log = new AutoUploadLog("GetLatesUpload_POP: " + ex.Message, _sqlConnectionString);
                return false;
            }
        }
 private void LogUpload(string message)
 {
     AutoUploadLog uploadLog = new AutoUploadLog(message, _sqlConnectionString);
     try
     {
         uploadLog.LogToDatabase();
     }
     catch
     {
     }
 }