/// <summary>
/// 郵件發送組件
/// </summary>
public class EmailUtils
{
static EmailUtils() {
MailHost = ConfigurationManager
MailUserName = ConfigurationManager
MailPsw = ConfigurationManager
MailFrom = ConfigurationManager
}
public static string MailFrom {
get;
set;
}
public static string MailHost {
get;
set;
}
public static string MailUserName {
get;
set;
}
public static string MailPsw {
get;
set;
}
/// <summary>
/// 發送郵件
/// </summary>
/// <param name=
/// <param name=
/// <param name=
/// <returns></returns>
public static bool Send(string mailto
var client = new SmtpClient();
client
client
client
client
System
message
message
message
message
try {
client
return true;
}
catch {
return false;
}
}
}
使用時直接調用 Send 方法即可
From:http://tw.wingwit.com/Article/program/net/201311/12764.html