Beispiel #1
0
        /// <summary>
        /// Constructor method.
        /// </summary>
        public SmtpNetworkEmailProvider(EmailProviderParameters parameters)
        {
            if (parameters == null)
            {
                throw new Exception(nameof(SmtpNetworkEmailProvider), new ArgumentNullException(nameof(parameters)));
            }

            _port = parameters.GetValue <int>("port");
            _host = parameters.GetValue <string>("host");

            _userName = parameters.GetValue <string>("host");
            _password = parameters.GetValue <string>("host");

            _enableSsl = parameters.GetValue <bool>("enableSsl");
        }
        /// <summary>
        /// Constructor method.
        /// </summary>
        public SmtpPickupDirectoryEmailProvider(EmailProviderParameters parameters)
        {
            if (parameters == null)
            {
                throw new Exception(nameof(SmtpNetworkEmailProvider), new ArgumentNullException(nameof(parameters)));
            }

            _appDataFolder            = HostingEnvironment.MapPath("~/App_Data");
            _specifiedPickupDirectory = parameters.GetValue <string>("emailsDirectory");

            if (_appDataFolder.IsNullOrWhiteSpace())
            {
                throw new ArgumentException(nameof(SmtpPickupDirectoryEmailProvider), new ArgumentException(nameof(_appDataFolder)));
            }

            if (_specifiedPickupDirectory.IsNullOrWhiteSpace())
            {
                throw new ArgumentException(nameof(SmtpPickupDirectoryEmailProvider), new ArgumentException(nameof(_specifiedPickupDirectory)));
            }

            if (!Path.IsPathRooted(_specifiedPickupDirectory))
            {
                _specifiedPickupDirectory = Path.Combine(_appDataFolder, _specifiedPickupDirectory.Trim('~').Trim('\\').Trim('/'));
            }

            if (!Directory.Exists(_specifiedPickupDirectory))
            {
                Directory.CreateDirectory(_specifiedPickupDirectory);
            }
        }