/// <summary> /// 执行方法。 /// </summary> /// <param name="argument">参数。</param> public override async Task ExecuteAsync(Argument argument) { var settings = await _settingsManager.GetSettingsAsync(); if (settings == null) { return; } var messages = await _emailManager.LoadAsync(EmailStatus.Pending); if (!messages.Any()) { return; } foreach (var message in messages) { try { await SendAsync(settings, message); await _emailManager.SetSuccessAsync(message.Id); } catch (Exception exception) { await _emailManager.SetFailuredAsync(message.Id, settings.MaxTryTimes); _logger.LogError(exception, "发送邮件错误"); } await Task.Delay(100); } }