读一段代码,最先解释满意的给全分结贴!!!在线等!!!!!
public SMTP()
{
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
MailSettingsSectionGroup mailSettings = NetSectionGroup.GetSectionGroup(config).MailSettings;
string mailFrom = mailSettings.Smtp.From;
string smtpServer = mailSettings.Smtp.Network.Host;
int smtpPort = mailSettings.Smtp.Network.Port;
string smtpUsername = mailSettings.Smtp.Network.UserName;
string password = mailSettings.Smtp.Network.Password;
smtpMail = new SmtpClient(smtpServer, smtpPort);
smtpMail.Credentials = new NetworkCredential(smtpUsername, password);
this._mailFrom = mailFrom;
this._displayName = smtpUsername;
}
public SMTP(string smtpServer, string userName, string password)
: this(null, smtpServer, userName, password)
{
}
/**//// <summary>
/// 邮件发送类
/// </summary>
/// <param name= "mailFrom "> 发件人地址 </param>
/// <param name= "smtpServer "> SMTP 服务器 </param>
/// <param name= "userName "> 用户名 </param>
/// <param name= "password "> 密码 </param>
public SMTP(string mailFrom, string smtpServer, string userName, string password)
: this(mailFrom, mailFrom, smtpServer, userName, password)
{