Example #1
0
        static int Main(string[] args)
        {
            ShowHeader();

            var settings = new Settings();
            var parser = new CommandLineParser(args);

            parser.ParseArgument("connectionString", v => settings.ConnectionString = v);
            parser.ParseArgument("sql", v => settings.Sql = v);
            parser.ParseArgument("from", v => settings.From = v);
            parser.ParseArgument("to", v => settings.To = v.Split(',', ';'));
            parser.ParseArgument("cc", v => settings.To = v.Split(',', ';'));
            parser.ParseArgument("bcc", v => settings.To = v.Split(',', ';'));
            parser.ParseArgument("subject", v => settings.Subject = v);
            parser.ParseArgument("body", v => settings.Body = v);
            parser.ParseArgument("smtpServer", v => settings.SmtpServer = v);
            parser.ParseArgument("smtpUsername", v => settings.SmtpUsername = v);
            parser.ParseArgument("smtpPassword", v => settings.SmtpPassword = v);
            parser.ParseArgument("smtpPort", v => v.ParseInt(i => settings.SmtpPort = i));
            settings.HtmlBody = parser.ArgumentExists("-html");

            if (!settings.IsValid)
            {
                ShowUsage(args);

                return -1;
            }

            Console.WriteLine("Executing using connfiguration:\n");
            Console.WriteLine(settings);

            var mailer = new CsvMailer(settings);

            return mailer.Process() ? 0 : -2;
        }
Example #2
0
 public CsvMailer(Settings settings)
 {
     this.settings = settings;
 }