Наследование: ICredentialsByHost
Пример #1
0
        public SmtpClient(string host, int port)
        {
#if CONFIGURATION_DEP
            SmtpSection cfg = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");

            if (cfg != null)
            {
                this.host = cfg.Network.Host;
                this.port = cfg.Network.Port;
#if false
                TargetName = cfg.Network.TargetName;
                if (this.TargetName == null)
                {
                    TargetName = "SMTPSVC/" + (host != null ? host : "");
                }
#endif

                if (cfg.Network.UserName != null)
                {
                    string password = String.Empty;

                    if (cfg.Network.Password != null)
                    {
                        password = cfg.Network.Password;
                    }

                    Credentials = new CCredentialsByHost(cfg.Network.UserName, password);
                }

                if (cfg.From != null)
                {
                    defaultFrom = new MailAddress(cfg.From);
                }
            }
#endif

            if (!String.IsNullOrEmpty(host))
            {
                this.host = host;
            }

            if (port != 0)
            {
                this.port = port;
            }
        }
Пример #2
0
		public SmtpClient (string host, int port) {
#if CONFIGURATION_DEP
			SmtpSection cfg = (SmtpSection) ConfigurationManager.GetSection ("system.net/mailSettings/smtp");

			if (cfg != null) {
				this.host = cfg.Network.Host;
				this.port = cfg.Network.Port;
#if NET_4_0
				this.enableSsl = cfg.Network.EnableSsl;
#endif
				TargetName = cfg.Network.TargetName;
				if (this.TargetName == null)
					TargetName = "SMTPSVC/" + (host != null ? host : "");

				
				if (cfg.Network.UserName != null) {
					string password = String.Empty;

					if (cfg.Network.Password != null)
						password = cfg.Network.Password;

					Credentials = new CCredentialsByHost (cfg.Network.UserName, password);
				}

				if (!String.IsNullOrEmpty (cfg.From))
					defaultFrom = new MailAddress (cfg.From);
			}
#else
			// Just to eliminate the warning, this codepath does not end up in production.
			defaultFrom = null;
#endif

			if (!String.IsNullOrEmpty (host))
				this.host = host;

			if (port != 0)
				this.port = port;
			else if (this.port == 0)
				this.port = 25;
		}
Пример #3
0
		public SmtpClient (string host, int port) {
#if CONFIGURATION_DEP
			SmtpSection cfg = (SmtpSection) ConfigurationManager.GetSection ("system.net/mailSettings/smtp");

			if (cfg != null) {
				this.host = cfg.Network.Host;
				this.port = cfg.Network.Port;
#if false
				TargetName = cfg.Network.TargetName;
				if (this.TargetName == null)
					TargetName = "SMTPSVC/" + (host != null ? host : "");
#endif
				
				if (cfg.Network.UserName != null) {
					string password = String.Empty;

					if (cfg.Network.Password != null)
						password = cfg.Network.Password;

					Credentials = new CCredentialsByHost (cfg.Network.UserName, password);
				}

				if (cfg.From != null)
					defaultFrom = new MailAddress (cfg.From);
			}
#endif

			if (!String.IsNullOrEmpty (host))
				this.host = host;

			if (port != 0)
				this.port = port;
		}