private static bool IsValidEmailSettings(EmailSettings emailSettings) { return !(emailSettings == null || emailSettings.Ip == null || emailSettings.Password == null || emailSettings.Port == null || emailSettings.UserName == null); }
public static EmailSettings SetDefaultParams() { EmailSettings defaultParams = new EmailSettings(); defaultParams.Ip = "mail.rubezh.ru"; defaultParams.Port = ((int)25).ToString(); defaultParams.UserName = "******"; defaultParams.Password = "******"; return defaultParams; }
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 EmailData() { Emails = new List<Email>(); EmailSettings = new EmailSettings(); }