/// <summary> /// Creates a new instance of Email. /// </summary> /// <param name="mailhost">Predefined mail server. Value should not be a CustomMail</param> /// <param name="uid">Mail account user id</param> /// <param name="pwd">Mail account password</param> public Email(MailHostEnum mailhost, string uid, string pwd) { _mailhost = mailhost; _uid = uid; _pwd = pwd; switch (mailhost) { case MailHostEnum.FMS: _host = fmsmail; break; case MailHostEnum.Gmail: _host = gmail; _port = 465; break; case MailHostEnum.YahooMail: _host = yahoomail; _port = 587; break; case MailHostEnum.CustomMail: case MailHostEnum.None: default: throw new Exception("Mail should not be other than FMS, Gmail or Yahoo mail host."); } if (_mailhost == MailHostEnum.FMS) { _smtp = new SmtpClient(_host); } else { if (_port > 0) { _smtp = new SmtpClient(_host, _port); } else { _smtp = new SmtpClient(_host); } _smtp.EnableSsl = true; _smtp.UseDefaultCredentials = false; } if (!String.IsNullOrEmpty(uid.RLTrim()) && !String.IsNullOrEmpty(pwd.RLTrim())) { _credentials = new NetworkCredential(uid, pwd); } }
/// <summary> /// Creates a new instance of Email. /// </summary> /// <param name="mailhost">Predefined mail server. Value should not be a CustomMail</param> /// <param name="uid">Mail account user id</param> /// <param name="pwd">Mail account password</param> public Email(MailHostEnum mailhost, string uid, string pwd) { _mailhost = mailhost; _uid = uid; _pwd = pwd; switch (mailhost) { case MailHostEnum.FMS: _host = fmsmail; break; case MailHostEnum.Gmail: _host = gmail; _port = 465; break; case MailHostEnum.YahooMail: _host = yahoomail; _port = 587; break; case MailHostEnum.CustomMail: case MailHostEnum.None: default: throw new Exception("Mail should not be other than FMS, Gmail or Yahoo mail host."); } if (_mailhost == MailHostEnum.FMS) _smtp = new SmtpClient(_host); else { if (_port > 0) _smtp = new SmtpClient(_host, _port); else _smtp = new SmtpClient(_host); _smtp.EnableSsl = true; _smtp.UseDefaultCredentials = false; } if (!String.IsNullOrEmpty(uid.RLTrim()) && !String.IsNullOrEmpty(pwd.RLTrim())) _credentials = new NetworkCredential(uid, pwd); }
/// <summary> /// Creates a new instance of Email. /// </summary> /// <param name="mailhost">Predefined mail server. Value should not be a CustomMail</param> public Email(MailHostEnum mailhost) : this(mailhost, "", "") { }
/// <summary> /// Creates a new instance of Email. /// </summary> /// <param name="mailhost">Predefined mail server. Value should not be a CustomMail</param> public Email(MailHostEnum mailhost) : this(mailhost,"","") { }