diff --git a/src/Umbraco.Core/Models/EmailMessage.cs b/src/Umbraco.Core/Models/EmailMessage.cs index e036f157d6..11483e1b20 100644 --- a/src/Umbraco.Core/Models/EmailMessage.cs +++ b/src/Umbraco.Core/Models/EmailMessage.cs @@ -8,19 +8,28 @@ namespace Umbraco.Core.Models public string To { get; } public string Subject { get; } public string Body { get; } - public bool IsBodyHtml { get; set; } = false; + public bool IsBodyHtml { get; } - public EmailMessage(string from, string to, string subject, string body) + public EmailMessage(string from, string to, string subject, string body, bool isBodyHtml) { - if (string.IsNullOrEmpty(from)) throw new ArgumentException("Value cannot be null or empty.", nameof(from)); - if (string.IsNullOrEmpty(to)) throw new ArgumentException("Value cannot be null or empty.", nameof(to)); - if (string.IsNullOrEmpty(subject)) throw new ArgumentException("Value cannot be null or empty.", nameof(subject)); - if (string.IsNullOrEmpty(body)) throw new ArgumentException("Value cannot be null or empty.", nameof(body)); + if (from == null) throw new ArgumentNullException(nameof(from)); + if (from.Length == 0) throw new ArgumentException("Value cannot be empty.", nameof(from)); + + if (to == null) throw new ArgumentNullException(nameof(to)); + if (to.Length == 0) throw new ArgumentException("Value cannot be empty.", nameof(to)); + + if (subject == null) throw new ArgumentNullException(nameof(subject)); + if (subject.Length == 0) throw new ArgumentException("Value cannot be empty.", nameof(subject)); + + if (body == null) throw new ArgumentNullException(nameof(body)); + if (body.Length == 0) throw new ArgumentException("Value cannot be empty.", nameof(body)); From = from; To = to; Subject = subject; Body = body; + + IsBodyHtml = isBodyHtml; } } } diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index 65fa7e3d47..37a3b5b072 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -82,10 +82,8 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods if (string.IsNullOrWhiteSpace(subject)) subject = "Umbraco Health Check Status"; - return new EmailMessage(to, RecipientEmail, subject, message) - { - IsBodyHtml = message.IsNullOrWhiteSpace() == false && message.Contains("<") && message.Contains("