public void SendMail(Message msg, List <User> recipients, List <User> ccs) { string mailPrefix = ""; try { var appSettingsJson = AppSettingsJson.GetAppSettings(); mailPrefix = appSettingsJson["EPSMailSubjectPrefix"]; } catch (System.IO.FileNotFoundException) { mailPrefix = "EPS Test"; } try { MailAddress sender = new MailAddress(msg.FromUser.Email, msg.FromUser.FullName); MailMessage mail = new MailMessage() { From = sender, Subject = "[" + mailPrefix + "]: " + msg.Subject, Body = msg.Body, IsBodyHtml = true }; foreach (User user in recipients) { mail.To.Add(new MailAddress(user.Email, user.FullName)); } if (ccs != null) { foreach (User user in ccs) { mail.CC.Add(new MailAddress(user.Email, user.FullName)); } } SmtpClient client = new SmtpClient { Port = _smtpConfig.Port, // Turnpike: 25, Aecom: 23 DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Host = _smtpConfig.Server// Turnpike: 156.75.163.42 Aecom: 192.29.28.71 }; client.Send(mail); } catch (Exception e) { //_logger.LogError(ex.StackTrace); Log.Error("MessageService.SendEmail Error:" + e.GetBaseException() + "\n" + e.StackTrace); Console.Write(e.StackTrace); //throw ex; } }
public static string UserFilesPhysicalPath() { if (string.IsNullOrEmpty(_userFilesPhysicalPath)) { var appSettingsJson = AppSettingsJson.GetAppSettings(); var UserFilesPhysicalPathSetting = appSettingsJson["UserFilesPhysicalPath"]; if (UserFilesPhysicalPathSetting.StartsWith("{wwwroot}")) { _userFilesPhysicalPath = UserFilesPhysicalPathSetting.Replace("{wwwroot}", ApplicationExeDirectory() + "\\wwwroot"); } } return(_userFilesPhysicalPath); }