Example #1
0
		private static bool IsValidEmailSettings(EmailSettings emailSettings)
		{
			return !(emailSettings == null ||
				emailSettings.Ip == null ||
				emailSettings.Password == null ||
				emailSettings.Port == null ||
				emailSettings.UserName == null);
		}
Example #2
0
		public static EmailSettings SetDefaultParams()
		{
			EmailSettings defaultParams = new EmailSettings();
			defaultParams.Ip = "mail.rubezh.ru";
			defaultParams.Port = ((int)25).ToString();
			defaultParams.UserName = "******";
			defaultParams.Password = "******";
			return defaultParams;
		}
Example #3
0
		public static void Send(EmailSettings senderParams, string to, string body, string subject = "")
		{
			try
			{
				if (IsValidEmailSettings(senderParams))
				{
					MailMessage message = new MailMessage(senderParams.UserName, to, subject, body);
					SmtpClient client = new SmtpClient(senderParams.Ip, int.Parse(senderParams.Port));
					client.DeliveryMethod = SmtpDeliveryMethod.Network;
					client.Credentials = new System.Net.NetworkCredential(senderParams.UserName, senderParams.Password);
					client.Send(message);
				}
				else
				{
					MessageBoxService.ShowError("Неверно заданы параметры smtp-сервера");
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "MailHelper.Send");
			}
		}
		public EmailSettingsViewModel()
		{
			EmailSettings = new EmailSettings();
		}
		public EmailSettingsViewModel(EmailSettings emailSettings)
		{
			EmailSettings = emailSettings;
		}
		public EmailConfigViewModel(EmailSettings senderParams)
		{
			Title = "Конфигурация smtp-сервера";
			EmailSettingsParamsViewModel = new EmailSettingsViewModel(senderParams);
			SetDefaultEmailSettingsCommand = new RelayCommand(OnSetDefaultEmailSettings);
		}
Example #7
0
		public EmailData()
		{
			Emails = new List<Email>();
			EmailSettings = new EmailSettings();
		}