Exemple #1
0
        private IEmail GetEmail()
        {
            IEmail email = new SimpleEmail();

            email.EmailAddress = this.FromAddress.Text;
            email.Subject      = this.Subject.Text;
            email.Body         = this.Body.Text;
            return(email);
        }
    private async Task ReaderLoopAsync()
    {
        while (!_cancelSource.Token.IsCancellationRequested)
        {
            try
            {
                SimpleEmail email = await _notificationEmails.Reader.ReadAsync();

                SmtpConfig       smtpConfig  = _configuration.GetValue <SmtpConfig>(nameof(SmtpConfig));
                EmailSendService sendService = new(smtpConfig.UserName, smtpConfig.Password,
                                                   smtpConfig.Host, smtpConfig.Port);
                await sendService.SendEmailAsync(email.FromAddress, email.ToAddress,
                                                 email.Subject, email.HtmlBody);
            }catch (Exception exception)
            {
                _logger.LogError(exception, "Exception in {Class}:{Method}",
                                 nameof(EmailChannel), nameof(ReaderLoopAsync));
            }
        }
    }
		private IEmail GetEmail()
		{
			IEmail email = new SimpleEmail();
			email.EmailAddress = this.FromAddress.Text;
			email.Subject = this.Subject.Text;
			email.Body = this.Body.Text;
			return email;
		}