邮件发送组件
1.先添加引入命名空间 System.Net.Mail
2.组件代码:
/// <summary>
/// 邮件发送组件
/// </summary>
public class EmailUtils
{
static EmailUtils() {
MailHost = ConfigurationManager.AppSettings["mailHost"];
MailUserName = ConfigurationManager.AppSettings["mailUserName"];
MailPsw = ConfigurationManager.AppSettings["mailPsw"];
MailFrom = ConfigurationManager.AppSettings["mailFrom"];
}
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="mailto">发送到</param>
/// <param name="title">标题</param>
/// <param name="msg"></param>
/// <returns></returns>
public static bool Send(string mailto, string title, string msg) {
var client = new SmtpClient();
client.Host = MailHost;
client.UseDefaultCredentials = false;
client.Credentials = new System
/// 邮件发送组件
/// </summary>
public class EmailUtils
{
static EmailUtils() {
MailHost = ConfigurationManager.AppSettings["mailHost"];
MailUserName = ConfigurationManager.AppSettings["mailUserName"];
MailPsw = ConfigurationManager.AppSettings["mailPsw"];
MailFrom = ConfigurationManager.AppSettings["mailFrom"];
}
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="mailto">发送到</param>
/// <param name="title">标题</param>
/// <param name="msg"></param>
/// <returns></returns>
public static bool Send(string mailto, string title, string msg) {
var client = new SmtpClient();
client.Host = MailHost;
client.UseDefaultCredentials = false;
client.Credentials = new System
补充:软件开发 , C# ,
上一个:C#压缩图片,可以指定图片模板高宽
下一个:C#动态调用委托的DLL