예제 #1
0
        public void Send(IExchangeEmailSender emailSender, ExchangeTestMessage testMessage, bool isHtml)
        {
            InitializeService();

            _emailSender = emailSender;

            var emailMessage = new EmailMessage(_exchangeService)
            {
                Body    = testMessage.Body,
                Subject = testMessage.Subject
            };

            if (isHtml)
            {
                emailMessage.Body.BodyType = BodyType.HTML;
            }
            else
            {
                emailMessage.Body.BodyType = BodyType.Text;
            }

            foreach (var to in testMessage.Tos)
            {
                if (!string.IsNullOrEmpty(to))
                {
                    emailMessage.ToRecipients.Add(to);
                }
            }

            foreach (var cC in testMessage.CCs)
            {
                if (!string.IsNullOrEmpty(cC))
                {
                    emailMessage.CcRecipients.Add(cC);
                }
            }

            foreach (var bcC in testMessage.BcCs)
            {
                if (!string.IsNullOrEmpty(bcC))
                {
                    emailMessage.BccRecipients.Add(bcC);
                }
            }

            foreach (var att in testMessage.Attachments)
            {
                if (!string.IsNullOrEmpty(att))
                {
                    emailMessage.Attachments.AddFileAttachment(att);
                }
            }

            _emailSender.Send(_exchangeService, emailMessage);
        }
예제 #2
0
 public void Send(IExchangeEmailSender emailSender, ExchangeTestMessage testMessage) => Send(emailSender, testMessage, true);