예제 #1
0
        public async Task SendMailWithOptions_Test()
        {
            var options = new PickupFolderMailerServiceOptions {
                BodyHtmlFormat   = "<html><body>{0}<hr/>This is footer</body></html>",
                BodyTextFormat   = "{0}\r\n--\r\nThis is footer",
                SubjectFormat    = "[test] {0}",
                DefaultFrom      = new MailAddressDto("*****@*****.**", "Example From"),
                DefaultSender    = new MailAddressDto("*****@*****.**", "Example Sender"),
                PickupFolderName = CreateTempFolder("options")
            };

            var mx  = new PickupFolderMailerService(options);
            var msg = new MailMessageDto {
                Subject  = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - subject",
                BodyText = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - text.",
                BodyHtml = "<p>ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy <b>v HTML</b>.</p>"
            };

            msg.To.Add(new MailAddressDto("*****@*****.**", "Example Recipient"));

            using (var ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("Test attachment file"))) {
                msg.Attachments.Add(new AttachmentDto {
                    Name = "attachment.txt", MimeType = "text/plain", Stream = ms
                });
                await mx.SendMessageAsync(msg);
            }

            Assert.True(EmlFileExists(mx.PickupFolderName));
        }
예제 #2
0
        public async Task SendPlainTextMail_Test()
        {
            var mx  = new PickupFolderMailerService(CreateTempFolder("plain"));
            var msg = new MailMessageDto {
                From     = new MailAddressDto("*****@*****.**", "Example Sender"),
                Subject  = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - subject",
                BodyText = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - text."
            };

            msg.To.Add(new MailAddressDto("*****@*****.**", "Example Recipient"));
            await mx.SendMessageAsync(msg);

            Assert.True(EmlFileExists(mx.PickupFolderName));
        }
예제 #3
0
        public async Task SendHtmlMail_Test()
        {
            var mx  = new PickupFolderMailerService(CreateTempFolder("html"));
            var msg = new MailMessageDto {
                From     = new MailAddressDto("*****@*****.**", "Example Sender"),
                Subject  = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - subject",
                BodyHtml = "<html><body><p>ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy <b>v HTML</b>.</p></body></html>"
            };

            msg.To.Add(new MailAddressDto("*****@*****.**", "Example Recipient"));
            await mx.SendMessageAsync(msg);

            Assert.True(EmlFileExists(mx.PickupFolderName));
        }
예제 #4
0
        public async Task SendMailWithAttachment_Test()
        {
            var mx  = new PickupFolderMailerService(CreateTempFolder("attachment"));
            var msg = new MailMessageDto {
                From     = new MailAddressDto("*****@*****.**", "Example Sender"),
                Subject  = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - subject",
                BodyText = "ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy - text.",
                BodyHtml = "<html><body><p>ОluЭouшk¤ k∙Є ·pьl ясbelskщ єdy <b>v HTML</b>.</p></body></html>"
            };

            msg.To.Add(new MailAddressDto("*****@*****.**", "Example Recipient"));

            using (var ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("Test attachment file"))) {
                msg.Attachments.Add(new AttachmentDto {
                    Name = "attachment.txt", MimeType = "text/plain", Stream = ms
                });
                await mx.SendMessageAsync(msg);
            }

            Assert.True(EmlFileExists(mx.PickupFolderName));
        }