コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="eMailOptions">Settings of the SMTP server</param>
        public EMailSender(IOptions <EMailOptions> eMailOptions)
        {
            _eMailOptions = eMailOptions.Value;

            if (!string.IsNullOrWhiteSpace(eMailOptions.Value.Host) && !string.IsNullOrWhiteSpace(_eMailOptions.UserName) &&
                !string.IsNullOrWhiteSpace(_eMailOptions.Password))
            {
                _client = new SmtpClient(_eMailOptions.Host, _eMailOptions.Port)
                {
                    Credentials = new NetworkCredential(_eMailOptions.UserName, _eMailOptions.Password),
                    EnableSsl   = _eMailOptions.EnableSsl
                };
            }
        }
コード例 #2
0
 public EMailService(IConfiguration configuration)
 {
     _configuration = configuration;
     _eMailOptions  = _configuration.GetSection("EMailConfiguration").Get <EMailOptions>();
 }