public async Task SendReceiptAsync(Receipt receipt, string user) { _logger.LogInformation($"Handling receipt with ID {receipt.ReceiptId}."); // Store in DB: _logger.LogInformation("Storing receipt..."); var receiptStoreItem = new ReceiptStoreItem { Id = receipt.ReceiptId, Items = receipt.Items, Created = _nowProvider(), Owner = user }; await _receiptStorage.SaveAsync(receiptStoreItem); var userSettings = await _userProfileReader.GetUserSettingsAsync(user); if (userSettings.IsTrue(UserSettingKeys.ReadsReceiptsOnline)) { _logger.LogInformation($"User {user} reads receipts online, not sending email."); } else { var toAddresses = userSettings.ListValues(UserSettingKeys.EmailAddresses); if (toAddresses.Length == 0) { _logger.LogError($"User {user} is missing email addresses."); } else { // Send email: _logger.LogInformation("Sending email..."); var to = userSettings[UserSettingKeys.EmailAddresses].Split(',', StringSplitOptions.RemoveEmptyEntries); var subject = "Here is your receipt"; var body = @$ "<html> <body> <p>Hi! Here is your receipt.</p> {receipt.ToHtml()}