public static void CheckPlaces() { foreach (var place in Places) { var currentUrl = $"{BaseUrl}{place.Value}{SuffixUrl}"; var htmlString = WebRequestHelper.GetHtmlString(currentUrl); SetLatestApartmentCountAndName(htmlString); if (_placesCount[place.Key].LatestCount != BoplatsHelper.LatestSearchCount && _placesCount[place.Key].LatestName != BoplatsHelper.LatestApartmentName) { var sb = new StringBuilder(); sb.Append($"Previous Count: {_placesCount[place.Key].LatestCount} <br /> Latest Count: <strong> {BoplatsHelper.LatestSearchCount} </strong>"); sb.Append("<br />"); sb.Append($"Previous Apartment: {_placesCount[place.Key].LatestName} <br /> Latest Apartment: <strong> {BoplatsHelper.LatestApartmentName}</strong>"); sb.Append("<br /><br />"); sb.Append($"Please check {currentUrl}"); var mailer = new Mailer(); var isSuccessful = mailer.SendEmail(Settings.FromEmail, Settings.FromEmailName, $"Boplats - Changes in {place.Key}'s apartment count", Settings.ToEmail, Settings.ToEmailName, null, sb.ToString()); _placesCount[place.Key].LatestCount = BoplatsHelper.LatestSearchCount; _placesCount[place.Key].LatestName = BoplatsHelper.LatestApartmentName; if (!isSuccessful) { throw new Exception("Failed to send email"); } } } }