示例#1
0
        public async Task TestSendEmailWithAttachments()
        {
            var mailSender = new MandrillSender(Options);

            var mailMessage = new MailMessage("test with attachment", @"test with attachment is ok ", new List <MailAddress>
            {
                new MailAddress {
                    Address = Address
                }
            })
            {
                IsHtml = true
            };

            var fs    = new FileStream(@"D:\\test.docx", FileMode.Open, FileAccess.Read);
            var bytes = new byte[fs.Length];

            fs.Read(bytes, 0, (int)fs.Length);

            mailMessage.Attachments = new List <MailAttachment>
            {
                new MailAttachment("test.pdf", @"D:\\test.pdf"),
                new MailAttachment("test.docx", @"D:\\test.docx"),
                new MailAttachment("test.docx", bytes)
            };

            var response = await mailSender.SendEmailAndReturnAsync(mailMessage);

            Assert.Equal(MailSendMessageResponseStatus.Sent, response.Status);
        }
示例#2
0
        public async Task TestSendEmailUsingHtml()
        {
            var mailSender = new MandrillSender(Options);

            var mailMessage = new MailMessage("test using html", @"<strong>Test<br/> is</br> ok</strong><img src=""cid:logo"">", new List <MailAddress>
            {
                new MailAddress {
                    Address = Address
                }
            })
            {
                IsHtml = true
            };

            mailMessage.Attachments = new List <MailAttachment>
            {
                new MailAttachment("test.pdf", @"D:\\test.pdf")
            };

            mailMessage.LinkedResources = new List <MailAttachment>
            {
                new MailAttachment("logo.png", @"D:\\logo.png")
                {
                    ContentId = "logo"
                }
            };

            var response = await mailSender.SendEmailAndReturnAsync(mailMessage);

            Assert.Equal(MailSendMessageResponseStatus.Sent, response.Status);
        }
示例#3
0
        public async Task TestSendEmail()
        {
            var mailSender = new MandrillSender(Options);

            var response = await mailSender.SendEmailAndReturnAsync("test", "test async is ok", Address);

            Assert.Equal(MailSendMessageResponseStatus.Sent, response.Status);
        }