예제 #1
0
        private bool SendEmail(string userEmail, HashSet <FailData> failedDatas)
        {
            var managerEmail = ActiveDirectoryHelper.GetManagerEmail(userEmail, ReadAppSetting("DomainName"));
            var cc           = string.IsNullOrEmpty(managerEmail) ? null : new[] { managerEmail };
            var body         = EmailBodyBuilder.Build(userEmail, failedDatas, managerEmail);

            var emailSender = new EmailManager();

            //return emailSender.SendEmail("Your Failed Builds:", body, new[] { userEmail }, cc);
            return(emailSender.SendEmail("Your Failed Builds", body, m_AdminEmails, null));
        }
예제 #2
0
        public IHttpActionResult SendEmail()
        {
            var addresses = new List <string>();

            addresses.Add("*****@*****.**");
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");

            foreach (var address in addresses)
            {
                mail.To.Add(address);
            }

            mail.Subject = "Cadre Test Email";

            var builder = new EmailBodyBuilder();

            var viewModels = new List <PostViewModel>();
            var posts      = database.Get <Post>();

            viewModels.AddRange(posts.Select(post => new PostViewModel()
            {
                Id             = post.Id,
                SubmitterName  = post.Submitter.Name,
                SubmitterEmail = post.Submitter.Email,
                Summary        = post.Summary,
                Details        = post.Details
            }));

            foreach (var viewModel in viewModels)
            {
                viewModel.EmailText = database.Get <Post>().SingleOrDefault(post => post.Id == viewModel.Id).GetEmailText();
            }

            mail.Body       = builder.Build(viewModels);
            mail.IsBodyHtml = true;

            SendSmtpEmail(mail);

            return(Ok(mail));
        }
예제 #3
0
        public IHttpActionResult SendEmail()
        {
            var addresses = new List<string>();
            addresses.Add("*****@*****.**");
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");

            foreach (var address in addresses)
            {
                mail.To.Add(address);
            }

            mail.Subject = "Cadre Test Email";

            var builder = new EmailBodyBuilder();

            var viewModels = new List<PostViewModel>();
            var posts = database.Get<Post>();

            viewModels.AddRange(posts.Select(post => new PostViewModel()
            {
                Id = post.Id,
                SubmitterName = post.Submitter.Name,
                SubmitterEmail = post.Submitter.Email,
                Summary = post.Summary,
                Details = post.Details
            }));

            foreach (var viewModel in viewModels)
            {
                viewModel.EmailText = database.Get<Post>().SingleOrDefault(post => post.Id == viewModel.Id).GetEmailText();
            }

            mail.Body = builder.Build(viewModels);
            mail.IsBodyHtml = true;

            SendSmtpEmail(mail);

            return Ok(mail);
        }