Example #1
0
        /// <summary>
        //отправка уведомления о новой промо-акции
        /// </summary>
        /// <param name="promotion"></param>
        void SendNotificationAboutUpdatePromotion(SupplierPromotion promotion)
        {
            try {
                var mailFrom = ConfigurationManager.AppSettings["NewPromotionNotifier"];
                var sender   = new DefaultSmtpSender(ConfigurationManager.AppSettings["SmtpServer"]);
                var message  = new MailMessage();
                message.Subject = "Обновлена промо-акция";
                message.From    = new MailAddress(mailFrom);
                message.To.Add(new MailAddress(mailFrom));
                message.BodyEncoding    = Encoding.UTF8;
                message.HeadersEncoding = Encoding.UTF8;
                message.Body            =
                    string.Format(@"Обновлена промо-акция.
Поставщик : {0}
Акция     : '{1}' ({2})
Период    : с {3} по {4}
Время     : {5}
Ip-адрес  : {6}", promotion.PromotionOwnerSupplier.Name, promotion.Name, promotion.Id,
                                  promotion.Begin.ToShortDateString(), promotion.End.ToShortDateString(),
                                  DateTime.Now.ToString("dd.MM.yyyy HH:mm"), HttpContext.Current?.Request?.UserHostAddress);
#if !DEBUG
                sender.Send(message);
#endif
            } catch (Exception e) {
#if DEBUG
                throw;
#endif
                log.Error(String.Format("Ошибка при отправке уведомления об обновлении промо-акции {0}", promotion.Id), e);
            }
        }
Example #2
0
 private void SendMessage(MailMessage message)
 {
     if (testMode)
     {
         logger.DebugFormat("Email service staat in testmodus");
         logger.DebugFormat("Bericht: {0}, naar: {1}", message.Subject, message.To);
         logger.Debug(message.Body);
     }
     else
     {
         defaultSmtpSender.Send(message);
     }
 }
Example #3
0
        void SendMailFromModerator(List <string> contacts, string subject, string body)
        {
            try {
                var sender  = new DefaultSmtpSender(ConfigurationManager.AppSettings["SmtpServer"]);
                var message = new MailMessage();
                message.Subject = subject;
                message.From    = new MailAddress(ConfigurationManager.AppSettings["ModeratorMailFrom"]);
                message.To.Add(string.Join(",", contacts));
                message.BodyEncoding    = Encoding.UTF8;
                message.HeadersEncoding = Encoding.UTF8;
                message.IsBodyHtml      = true;
                message.Body            = body;
                sender.Send(message);
            }
            catch (Exception e) {
#if DEBUG
                throw;
#endif
                log.Error(String.Format("Ошибка при отправке письма от модератора {0}", subject), e);
            }
        }
 /// <summary>
 /// Sends a message.
 /// </summary>
 /// <param name="from">From field</param>
 /// <param name="to">To field</param>
 /// <param name="subject">e-mail's subject</param>
 /// <param name="messageText">message's body</param>
 public void Send(string from, string to, string subject, string messageText)
 {
     sender.Send(from, to, subject, messageText);
 }