コード例 #1
0
        public bool WithMailService()
        {
            /*
             * Mail service initialization
             */
            if (!RequiredEnvironmentVariables.ContainsKey("SENDGRID_API_KEY") ||
                !RequiredEnvironmentVariables.ContainsKey("SENDGRID_SENDER_EMAIL") ||
                !RequiredEnvironmentVariables.ContainsKey("SENDGRID_SENDER_NAME"))
            {
                LoggingService.WriteLogs(BLoggingServiceMessageUtility.Single(EBLoggingServiceLogType.Critical, "SENDGRID_API_KEY, SENDGRID_SENDER_EMAIL, SENDGRID_SENDER_NAME parameters must be provided and valid."), ProgramID, "Initialization");
                return(false);
            }

            MailService = new BMailServiceSendGrid(
                RequiredEnvVars["SENDGRID_API_KEY"],
                RequiredEnvVars["SENDGRID_SENDER_EMAIL"],
                RequiredEnvVars["SENDGRID_SENDER_NAME"],
                (string Message) =>
            {
                LoggingService.WriteLogs(BLoggingServiceMessageUtility.Single(EBLoggingServiceLogType.Critical, Message), ProgramID, "Initialization");
            });

            if (MailService == null || !MailService.HasInitializationSucceed())
            {
                LoggingService.WriteLogs(BLoggingServiceMessageUtility.Single(EBLoggingServiceLogType.Critical, "Mail service initialization has failed."), ProgramID, "Initialization");
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public bool Start()
        {
            PrintAction?.Invoke("BEmailServicesTest->Info-> Test is starting.");

            if (SelectedMailService == null)
            {
                PrintAction?.Invoke("BEmailServicesTest->Error-> Given SelectedMailService is null.");
                return(false);
            }

            if (!SelectedMailService.HasInitializationSucceed())
            {
                PrintAction?.Invoke("BEmailServicesTest->Error-> Initialization failed.");
                return(false);
            }
            PrintAction?.Invoke("BEmailServicesTest->Log-> Initialization succeed.");

            if (!SelectedMailService.SendEmails(new List <BMailServiceMailStruct>
            {
                new BMailServiceMailStruct(new BMailServicerReceiverStruct("*****@*****.**", "Burak Kara"), "Test e-mail - 1", "Burak.IO Test E-mail - 1", "<strong>Burak.IO Test E-mail with strong html wrapper - 1</strong>"),
                new BMailServiceMailStruct(new BMailServicerReceiverStruct("*****@*****.**", "Burak Kara G-mail - 2"), "Test e-mail", "Burak.IO Test E-mail - 2", "<strong>Burak.IO Test E-mail with strong html wrapper - 2</strong>")
            },
                                                Console.WriteLine))
            {
                return(false);
            }

            if (!SelectedMailService.BroadcastEmail(new List <BMailServicerReceiverStruct>
            {
                new BMailServicerReceiverStruct("*****@*****.**", "Burak Kara"),
                new BMailServicerReceiverStruct("*****@*****.**", "Burak Kara G-mail - 2")
            },
                                                    "Test broadcast e-mail",
                                                    "Burak.IO broadcast test e-mail",
                                                    "<strong>Burak.IO broadcast test e-mail with strong html wrapper</strong>",
                                                    Console.WriteLine))
            {
                return(false);
            }

            return(true);
        }