Esempio n. 1
0
        // [TestMethod]
        public void Send_Email_With_Custom_Smtp_Factory()
        {
            var model = new TestModel()
            {
                FirstName    = "TestFirstName",
                LastName     = "TestLastName",
                CreationDate = DateTime.Now
            };

            var smtpClient = new MockSmtpClientFactory();

            GlobalConfiguration.Configuration.SmtpClientFactory = smtpClient;

            var messageId   = Guid.NewGuid().ToString();
            var emailConfig = QMailerService.CreateEmailConfig(messageId);

            emailConfig.SetView("test")
            .AddRecipient(new EmailAddress()
            {
                Address = "*****@*****.**"
            })
            .AddParameter("param1", "value1")
            .SetSender("*****@*****.**", "marc", "god", "code", true)
            .SetModel(model);

            QMailerService.SendAsync(emailConfig);

            Assert.AreNotEqual(0, smtpClient.CreateCount);
        }
Esempio n. 2
0
        public void Add_Attachment()
        {
            var model = new TestModel()
            {
                FirstName    = "TestFirstName",
                LastName     = "TestLastName",
                CreationDate = DateTime.Now
            };

            var messageId   = Guid.NewGuid().ToString();
            var emailConfig = QMailerService.CreateEmailConfig(messageId);

            emailConfig.SetView("test")
            .AddRecipient(new EmailAddress()
            {
                Address = "*****@*****.**"
            })
            .AddParameter("param1", "value1")
            .SetSender("*****@*****.**", "marc", "god", "code", true)
            .AddAttachment("filename.pdf", "application/pdf", @".\file.pdf")
            .SetModel(model);


            System.IO.File.WriteAllText(@".\base64.txt", emailConfig.Attachments[0].Content);
        }
Esempio n. 3
0
        public ActionResult Contact(string templateName)
        {
            string messageId   = Guid.NewGuid().ToString();
            var    emailConfig = QMailerService.CreateEmailConfig(messageId);

            emailConfig.SetView(templateName)
            .AddRecipient(new QMailer.EmailAddress()
            {
                Address = "*****@*****.**", SendingType = EmailSendingType.To
            });

            QMailerService.SendAsync(emailConfig);

            return(View());
        }
Esempio n. 4
0
        public void Send_Email()
        {
            var model = new TestModel()
            {
                FirstName    = "TestFirstName",
                LastName     = "TestLastName",
                CreationDate = DateTime.Now
            };

            var messageId   = Guid.NewGuid().ToString();
            var emailConfig = QMailerService.CreateEmailConfig(messageId);

            emailConfig.SetView("test")
            .AddRecipient(new EmailAddress()
            {
                Address = "*****@*****.**"
            })
            .AddParameter("param1", "value1")
            .SetSender("*****@*****.**", "marc", "god", "code", true)
            .SetModel(model);

            QMailerService.SendAsync(emailConfig);
        }
Esempio n. 5
0
        public EmailConfig CreateEmailConfig(string messageId)
        {
            var emailConfig = QMailerService.CreateEmailConfig(messageId);

            return(emailConfig);
        }