3.最后是用到的SMTP辅助类
public class EmailClient
{
private string smtpServer;
private string senderAddress;
public EmailClient(string smtpServer)
{
this.smtpServer = smtpServer;
this.senderAddress = string.Empty;
}
public void SendEmail(string fromAddress, string toAddress, string subject, string messageBody)
{
SmtpClient smtp = new SmtpClient(smtpServer);
MailMessage email = new MailMessage();
email.From = new MailAddress(fromAddress);
email.To.Add(toAddress);
email.Subject = subject;
email.Body = messageBody;
smtp.Send(email);
}
}










