public async Task SendErrorsAsync(IEnumerable <ServiceCheckResultDto> serviceCheckResults) { Guard.Against.NullOrEmpty(serviceCheckResults, nameof(serviceCheckResults)); try { var message = _emailBuilder.BuildUnhealthyServicesEmail(serviceCheckResults, _smtpConfiguration.SenderName, _smtpConfiguration.SenderEmail, _notificationConfiguration.NotificationEmails); await _smtpClient.ConnectAsync(_smtpConfiguration.SmtpServer, _smtpConfiguration.SmtpPort); await _smtpClient.AuthenticateAsync(_smtpConfiguration.SenderUserName, _smtpConfiguration.SenderPassword); await _smtpClient.SendAsync(message); await _smtpClient.DisconnectAsync(true); } catch (Exception ex) { _logger.LogError("Failed to send email about unhealthy services", ex); } }