protected void SendEmailToBilling(IEmailDtoSupport model,string from, string subject, string body) { try { SetEmailDtoForBilling(model, from, subject, body); SendEmail(model.EmailDto); } catch (Exception ex) { Log.Error("Exception:", ex); model.EmailDto.Error = "Исключение: " + ex.GetBaseException().Message; } }
protected void SetEmailDtoForBilling(IEmailDtoSupport model, string from, string subject, string body) { EmailDto dto = new EmailDto(); Settings settings = SettingsDao.LoadFirst(); if (settings == null) { dto.Error = "Отсутствуют настройки в базе данных."; model.EmailDto = dto; return; } dto.SmtpServer = settings.BillingSmtp; dto.SmtpPort = settings.BillingPort; dto.UserName = settings.BillingLogin; dto.Password = settings.BillingPassword; dto.From = from ?? settings.NotificationEmail; dto.To = settings.BillingEmail; dto.Subject = subject; dto.Body = body; model.EmailDto = dto; }
protected void SendEmail(Settings settings, IEmailDtoSupport model, string to, string subject, string body) { try { SetEmailDto(settings,model, to, subject, body); SendEmail(model.EmailDto); } catch (Exception ex) { Log.Error("Exception:", ex); model.EmailDto.Error = "Исключение: " + ex.GetBaseException().Message; } }