コード例 #1
0
        public void Send_Email()
        {
            var sender = new QMailer.SendinBlue.SendInBlueSender(Bus);

            var emailSender    = System.Configuration.ConfigurationManager.AppSettings["SIBSenderEmail"];
            var emailRecipient = System.Configuration.ConfigurationManager.AppSettings["SIBRecipientEmail"];

            var message = new EmailMessage();

            message.Body       = "<html><body>Hello world</body></html>";
            message.Subject    = "Test SendInBlue";
            message.IsBodyHtml = true;
            message.MessageId  = Guid.NewGuid().ToString();
            message.Recipients = new List <EmailAddress>();
            message.Recipients.Add(new EmailAddress()
            {
                Address     = emailRecipient,
                DisplayName = $"-- {emailRecipient} --",
                RecipientId = Guid.NewGuid().ToString(),
                SendingType = EmailSendingType.To
            });
            message.Sender = new Sender()
            {
                DisplayName = $"-- {emailSender} --",
                Email       = emailSender
            };

            sender.Send(message);

            // SendinBlue.StatusChecker.Current.CheckPendingMessage()

            //Assert.IsNotNull(result);


            //var statusCheck = client.GetMessageHistory(result.MessageId);

            //Assert.IsNotNull(statusCheck);
            //Assert.IsNotNull(statusCheck.Events);

            //var lastStatus = statusCheck.Events.Last();
            //Assert.IsNotNull(lastStatus);
        }
コード例 #2
0
        public void Send_Email_WithInterceptor()
        {
            var sender = new QMailer.SendinBlue.SendInBlueSender(Bus);

            var emailSender    = System.Configuration.ConfigurationManager.AppSettings["SIBSenderEmail"];
            var emailRecipient = System.Configuration.ConfigurationManager.AppSettings["SIBRecipientEmail"];


            QMailerService.RegisterInterceptor(typeof(MockInterceptor));

            var message = new EmailMessage();

            message.Body       = "Hello world";
            message.IsBodyHtml = false;
            message.Subject    = "Test SendInBlue";
            message.MessageId  = Guid.NewGuid().ToString();
            message.Recipients = new List <EmailAddress>();
            message.Recipients.Add(new EmailAddress()
            {
                Address     = emailRecipient,
                DisplayName = $"-- {emailRecipient} --",
                RecipientId = Guid.NewGuid().ToString(),
                SendingType = EmailSendingType.To
            });
            message.Sender = new Sender()
            {
                DisplayName = $"-- {emailSender} --",
                Email       = emailSender
            };

            sender.Send(message);

            DateTime retryMaxTime = DateTime.Now.Add(new TimeSpan(0, 1, 0));

            while (message.Body != "executed" && DateTime.Now < retryMaxTime)
            {
                Thread.Sleep(1000);
            }
            Assert.IsTrue(message.Body == "executed");
        }