/// <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 ProcessLastestUpload()
        {
            try
            {
                MMDAutomation.DatasheetProcessing.ICMSAutoOrders autoOrders = new MMDAutomation.DatasheetProcessing.ICMSAutoOrders(_attachment, _sqlConnectionString);
                try
                {
                    autoOrders.UploadNotAllocated();
                }
                catch (Exception ex)
                {
                    MessageLog msg = new MessageLog();
                    msg.SendNotification("There was a problem processing the file for NOTALLOCATED.  " + Environment.NewLine + ex.Message, "Problem in WADALAOR file", _notifyTo,
                        _icmsEmailAddress, _icmsEmailAddress, _smtpPort, _smtpHost, _smtpPassword, _attachment);

                }
                try
                {
                    autoOrders.UploadAllocated();
                }
                catch (Exception ex)
                {
                    MessageLog msg = new MessageLog();
                    msg.SendNotification("There was a problem processing the file for ALLOCATED.  " + Environment.NewLine + ex.Message, "Problem in WADALAOR file", _notifyTo,
                        _icmsEmailAddress, _icmsEmailAddress, _smtpPort, _smtpHost, _smtpPassword, _attachment);
                }
                try
                {
                    autoOrders.UploadTTIn();
                }
                catch (Exception ex)
                {
                    MessageLog msg = new MessageLog();
                    msg.SendNotification("There was a problem processing the file for TT.  " + Environment.NewLine + ex.Message, "Problem in WADALAOR file", _notifyTo,
                        _icmsEmailAddress, _icmsEmailAddress, _smtpPort, _smtpHost, _smtpPassword, _attachment);
                }
            }
            catch (Exception ex)
            {
                LogUpload("Could not process auto orders: " + ex.Message);
            }
        }