Exemplo n.º 1
0
 //Constructor
 public Email()
 {
     request = new SendEmailRequest()
     {
         To          = Config.To,
         ReplyTo     = Config.ReplyTo,
         Subject     = Config.Subject,
         Body        = Config.Body,
         From        = Config.From,
         IsHtml      = Config.IsHtml,
         Priority    = Config.Priority,
         UseExigoApi = Config.UseExigoApi,
     };
 }
Exemplo n.º 2
0
        public static void SendEmail(SendEmailRequest request)
        {
            if (request.SMTPConfiguration == null)
            {
                return;
            }

            // Create a list of emails we will send
            var emails = new List <MailMessage>();

            // SMTP Credentials
            SmtpClient smtp = new SmtpClient(request.SMTPConfiguration.Server, request.SMTPConfiguration.Port);

            smtp.Credentials    = new System.Net.NetworkCredential(request.SMTPConfiguration.Username, request.SMTPConfiguration.Password);
            smtp.EnableSsl      = request.SMTPConfiguration.EnableSSL;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

            // Send an email to each recipient
            foreach (var recipientEmail in request.To)
            {
                // Create the MailMessage object
                MailMessage email = new MailMessage(request.From, recipientEmail);
                email.Priority   = request.Priority;
                email.IsBodyHtml = request.IsHtml;

                // Reply to
                foreach (var replyTo in request.ReplyTo)
                {
                    email.ReplyToList.Add(replyTo);
                }

                // Subject and body
                email.Subject = request.Subject;
                email.Body    = request.Body;

                // Add the email to the collection
                emails.Add(email);
            }

            // Send the emails
            foreach (var email in emails)
            {
                Task.Factory.StartNew(() =>
                {
                    smtp.Send(email);
                });
            }
        }
Exemplo n.º 3
0
        public static void SendEmail(SendEmailRequest request)
        {
            if(request.SMTPConfiguration == null)
            {
                return;
            }

            // Create a list of emails we will send
            var emails = new List<MailMessage>();

            // SMTP Credentials
            SmtpClient smtp     = new SmtpClient(request.SMTPConfiguration.Server, request.SMTPConfiguration.Port);
            smtp.Credentials    = new System.Net.NetworkCredential(request.SMTPConfiguration.Username, request.SMTPConfiguration.Password);
            smtp.EnableSsl      = request.SMTPConfiguration.EnableSSL;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

            // Send an email to each recipient
            foreach (var recipientEmail in request.To)
            {
                // Create the MailMessage object
                MailMessage email = new MailMessage(request.From, recipientEmail);
                email.Priority    = request.Priority;
                email.IsBodyHtml  = request.IsHtml;

                // Reply to
                foreach (var replyTo in request.ReplyTo)
                {
                    email.ReplyToList.Add(replyTo);
                }

                // Subject and body
                email.Subject = request.Subject;
                email.Body    = request.Body;

                // Add the email to the collection
                emails.Add(email);
            }

            // Send the emails
            foreach (var email in emails)
            {
                Task.Factory.StartNew(() =>
                {
                    smtp.Send(email);
                });
            }
        }
Exemplo n.º 4
0
        public static void SendEmail(SendEmailRequest request)
        {
            var sendEmailRequest = new Common.Api.ExigoWebService.SendEmailRequest
            {
                MailFrom = request.From,
                Subject  = request.Subject,
                Body     = request.Body
            };

            // Send the emails
            var tasks = new List <Task>();

            foreach (var email in request.To)
            {
                tasks.Add(
                    Task.Factory.StartNew(() =>
                {
                    sendEmailRequest.MailTo = email;
                    ExigoDAL.WebService().SendEmail(sendEmailRequest);
                }));
            }
            Task.WaitAll(tasks.ToArray());
        }