/// <summary> /// 取得SmtpClient /// </summary> /// <param name="smtp"></param> /// <returns></returns> private SmtpClient GetSmtpClient(CustomSmtpList smtp) { SmtpClient tmp; switch (smtp) { case CustomSmtpList.None: tmp = null; break; case CustomSmtpList.Outlook: tmp = new SmtpClient(); break; case CustomSmtpList.Gmail: tmp = new SmtpClient("smtp.gmail.com", 587); break; case CustomSmtpList.Yahoo: tmp = new SmtpClient("smtp.mail.yahoo.com", 587); break; case CustomSmtpList.Hotmail: tmp = new SmtpClient("smtp.live.com", 587); break; default: tmp = null; break; } return(tmp); }
public CustomMail(CustomSmtpList smtp, string EmailAccont, string Password) { OringeSendEmail = GetSmtpClient(smtp); OringeSendEmail.EnableSsl = true; OringeSendEmail.Credentials = new System.Net.NetworkCredential(EmailAccont, Password); this.initEmailAccount = EmailAccont; }