private static void Main(string[] args) { startFolder = Path.GetFullPath(Environment.CurrentDirectory); startFolder += @"\"; //do checks if (!File.Exists(startFolder + RECIPIENTS_FILE)) { Console.WriteLine("Recipients file not found"); } if (!File.Exists(startFolder + SUBJECT_FILE_NAME)) { Console.WriteLine("Subject file not found"); } if (!File.Exists(startFolder + EMAILBODY_HTML)) { Console.WriteLine("Email body file not found"); } FileStream stream = File.Open(startFolder + RECIPIENTS_FILE, FileMode.Open, FileAccess.Read); //1. Reading from a binary Excel file ('97-2003 format; *.xls) IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream); //4. DataSet - Create column names from first row excelReader.IsFirstRowAsColumnNames = false; DataSet result = excelReader.AsDataSet(); int index = -1; foreach (DataRow row in result.Tables[0].Rows) { try { Recipinet ss = new Recipinet(); ss.Email = row[0].ToString(); if (string.IsNullOrEmpty(ss.Email)) { continue; } list.Add(ss); Console.WriteLine(ss.Email); } catch (Exception ex) { Console.WriteLine(ex.Message); } } excelReader.Close(); output.Append("read " + list.Count + " records"); output.Append(Environment.NewLine); if (list.Count == 0) { Console.WriteLine("No recipients found"); return; } Console.WriteLine(list.Count + " records"); Process(); File.WriteAllText(startFolder + "log.txt", output.ToString()); Console.WriteLine("Done"); Console.Read(); }