Ejemplo n.º 1
0
        public void SendMail(string from, string to, string subject, string body, IEnumerable <AttachStream> attachFiles)
        {
            MailMessage message = new MailMessage(from, ReplaceMailTo(to));

            message.IsBodyHtml = true;
            message.Subject    = subject;
            message.Body       = body;

            SmtpClient smtp = new SmtpClient();

            foreach (AttachStream item in attachFiles)
            {
                try
                {
                    Attachment attach = AttachmentFactory.CreateAttachFrom(item.FileStream, item.FileName);
                    message.Attachments.Add(attach);
                }
                catch (AttachmentFileIsNotFoundException ex)
                {
                    LoggerFactory.CreateLog().LogError("Cannot AttachFile", ex);
                }
            }

            smtp.Send(message);

            IEmailService mailLog = new TextLoggingEmailService();

            mailLog.SendMail(from, to, subject, body, message.Attachments);
        }
Ejemplo n.º 2
0
        public void SendMail(MailMessage mailMessage)
        {
            SmtpClient smtp = new SmtpClient();

            IList <MailAddress> mailAddresses = new List <MailAddress>();

            foreach (MailAddress item in mailMessage.To)
            {
                mailAddresses.Add(new MailAddress(ReplaceMailTo(item.Address)));
            }
            mailMessage.To.Clear();
            foreach (MailAddress item in mailAddresses)
            {
                mailMessage.To.Add(item);
            }
            smtp.Send(mailMessage);

            IEmailService mailLog = new TextLoggingEmailService();

            if (mailMessage.Attachments.Count > 0)
            {
                mailLog.SendMail(mailMessage.From.Address, String.Join(";", mailMessage.To.Select(a => a.Address).ToArray()), mailMessage.Subject, mailMessage.Body, mailMessage.Attachments);
            }
            else
            {
                mailLog.SendMail(mailMessage.From.Address, String.Join(";", mailMessage.To.Select(a => a.Address).ToArray()), mailMessage.Subject, mailMessage.Body);
            }
        }
Ejemplo n.º 3
0
        public void SendMail(string from, string to, string subject, string body)
        {
            MailMessage message = new MailMessage(from, ReplaceMailTo(to));

            message.IsBodyHtml = true;
            message.Subject    = subject;
            message.Body       = body;

            SmtpClient smtp = new SmtpClient();

            smtp.Send(message);

            IEmailService mailLog = new TextLoggingEmailService();

            mailLog.SendMail(from, to, subject, body);
        }
Ejemplo n.º 4
0
        public void SendMail(MailMessage mailMessage)
        {
            SmtpClient smtp = new SmtpClient();

            smtp.Send(mailMessage);

            IEmailService mailLog = new TextLoggingEmailService();

            if (mailMessage.Attachments.Count > 0)
            {
                mailLog.SendMail(mailMessage.From.Address, String.Join(";", mailMessage.To.Select(a => a.Address).ToArray()), mailMessage.Subject, mailMessage.Body, mailMessage.Attachments);
            }
            else
            {
                mailLog.SendMail(mailMessage.From.Address, String.Join(";", mailMessage.To.Select(a => a.Address).ToArray()), mailMessage.Subject, mailMessage.Body);
            }
        }
Ejemplo n.º 5
0
        public void SendMail(string from, string to, string subject, string body, IEnumerable <Attachment> attachFiles)
        {
            MailMessage message = new MailMessage(from, ReplaceMailTo(to));

            message.IsBodyHtml = true;
            message.Subject    = subject;
            message.Body       = body;

            SmtpClient smtp = new SmtpClient();

            foreach (Attachment item in attachFiles)
            {
                message.Attachments.Add(item);
            }

            smtp.Send(message);

            IEmailService mailLog = new TextLoggingEmailService();

            mailLog.SendMail(from, to, subject, body, message.Attachments);
        }