Ejemplo n.º 1
0
        public ActionResult ProcessJob(Job job)
        {
            _logger.Info("Launched client e-mail action");

            var mailInfo = _mailHelper.CreateMailInfo(job, job.Profile.EmailClientSettings);

            return(Process(mailInfo));
        }
Ejemplo n.º 2
0
        private ActionResult CreateMailMessage(Job job, EmailSmtpSettings mailSettings, SmtpAccount sender, out MailMessage mailMessage)
        {
            var mailInfo = _mailHelper.CreateMailInfo(job, mailSettings);

            mailMessage = null;
            try
            {
                mailMessage = mailMessage = new MailMessage(sender.Address, mailInfo.Recipients)
                {
                    Subject    = mailInfo.Subject,
                    Body       = mailInfo.Body,
                    IsBodyHtml = mailInfo.IsHtml
                };

                if (!string.IsNullOrWhiteSpace(mailInfo.RecipientsBcc)) //Prevent MailMessage from throwing and exception if BCC is not set
                {
                    mailMessage.Bcc.Add(mailInfo.RecipientsBcc);
                }

                if (!string.IsNullOrWhiteSpace(mailInfo.RecipientsCc)) //Prevent MailMessage from throwing and exception if CC is not set
                {
                    mailMessage.CC.Add(mailInfo.RecipientsCc);
                }
            }
            catch
            {
                return(new ActionResult(ErrorCode.Smtp_InvalidRecipients));
            }

            foreach (var attachment in mailInfo.Attachments)
            {
                try
                {
                    mailMessage.Attachments.Add(new Attachment(attachment));
                }
                catch
                {
                    Logger.Error("Invalid SMTP attachment: " + attachment);
                    return(new ActionResult(ErrorCode.Smtp_InvalidAttachmentFiles));
                }
            }

            return(new ActionResult());
        }
Ejemplo n.º 3
0
        public ActionResult ProcessJob(Job job)
        {
            var mailInfo = _mailHelper.CreateMailInfo(job, job.Profile.EmailClientSettings);

            return(ProcessMailInfo(mailInfo));
        }