private static IEnumerable <Contract> GetContracts(string ContractFilePath)
        {
            var app = new Excel.Application();

            Excel.Workbook excelWorkbook = app.Workbooks.Open(ContractFilePath, 0,
                                                              false, 5, System.Reflection.Missing.Value,
                                                              System.Reflection.Missing.Value,
                                                              false, System.Reflection.Missing.Value,
                                                              System.Reflection.Missing.Value, true, false,
                                                              System.Reflection.Missing.Value, false, false, false);

            //
            //app.Visible = true;
            var result = ContractCollector.GetContracts(app);

            app.Quit();
            return(result);
        }
        /// <summary>
        /// 根据
        /// </summary>
        /// <param name="contractFilePath"></param>
        /// <returns></returns>
        public static IEnumerable <Contract> GetContracts(string contractFilePath)
        {
            var app = new Microsoft.Office.Interop.Excel.Application();

            Microsoft.Office.Interop.Excel.Workbook excelWorkbook = app.Workbooks.Open(contractFilePath, 0,
                                                                                       false, 5, System.Reflection.Missing.Value,
                                                                                       System.Reflection.Missing.Value,
                                                                                       false, System.Reflection.Missing.Value,
                                                                                       System.Reflection.Missing.Value, true, false,
                                                                                       System.Reflection.Missing.Value, false, false, false);

            //
            //app.Visible = true;
            var result = ContractCollector.GetContracts(app);

            app.Quit();
            return(result);
        }
        private static IEnumerable <Contract> GetContracts(_MailItem mail)
        {
            var attachment = mail.Attachments[1];

            var strFilePath    = Path.Combine(Path.GetTempPath(), attachment.FileName);
            var arrachmentType = attachment.Type;
            //var path = attachment.GetTemporaryFilePath();
            var attachmentClass   = attachment.Class;
            var attachmentSession = attachment.Session;

            if (File.Exists(strFilePath))
            {
                try
                {
                    File.Delete(strFilePath);
                }
                catch (Exception e)
                {
                    MessageBox.Show(string.Format("附件临时文件{0}已被占用请删除后再执行同步操作.",
                                                  strFilePath));
                    var trace = e.StackTrace;
                    return(new List <Contract>());
                }
            }
            attachment.SaveAsFile(strFilePath);


            var app = new Excel.Application();

            Excel.Workbook excelWorkbook = app.Workbooks.Open(strFilePath, 0,
                                                              false, 5, System.Reflection.Missing.Value,
                                                              System.Reflection.Missing.Value,
                                                              false, System.Reflection.Missing.Value,
                                                              System.Reflection.Missing.Value, true, false,
                                                              System.Reflection.Missing.Value, false, false, false);

            //
            //app.Visible = true;
            var result = ContractCollector.GetContracts(app);

            app.Quit();
            return(result);
        }