一个发送电子邮件的类(C#&asp.net2)
2007-01-10 12:08
609 查看
public class SystemMail
...{
public SystemMail() ...{ }
...#region
private string _to;
public string To
...{
get ...{ return _to; }
set ...{ _to = value; }
}
private string _from = "abc@163.com";
public string From
...{
get ...{ return _from; }
set ...{ _from = value; }
}
private string _subject;
public string Subject
...{
get ...{ return _subject; }
set ...{ _subject = value; }
}
private string _body;
public string Body
...{
get ...{ return _body; }
set ...{ _body = value; }
}
#endregion
private string _adminEmail = "abc@163.com";
public string AdminEmail
...{
get ...{ return _adminEmail; }
set ...{ _adminEmail = value; }
}
private string _smtpServer = "smtp.163.com";
public string SmtpServer
...{
get ...{ return _smtpServer; }
set ...{ _smtpServer = value; }
}
private string _BodyFormat = "html";
public string BodyFormat
...{
get ...{ return _BodyFormat; }
set ...{ _BodyFormat = value; }
}
private string _BodyEncoding = "gb2312";
public string BodyEncoding
...{
get ...{ return _BodyEncoding; }
set ...{ _BodyEncoding = value; }
}
private string _password = "111111";
public string Password
...{
get ...{ return _password; }
set ...{ _password = value; }
}
private string _userName = "online";
public string UserName
...{
get ...{ return _userName; }
set ...{ _userName = value; }
}
public bool Send()
...{
try
...{
System.Net.Mail.SmtpClient SC = new SmtpClient();
SC.Host = this.SmtpServer;
SC.UseDefaultCredentials = false;
SC.Port = 25;
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(this.UserName, this.Password);
SC.Credentials = basicAuthenticationInfo;
MailMessage em = new MailMessage();
em.To.Add(new System.Net.Mail.MailAddress(this.To));
em.From = new MailAddress(this.From);
em.Subject = this.Subject;
em.Body = this.Body;
em.SubjectEncoding = System.Text.Encoding.GetEncoding(_BodyEncoding);
if (_BodyEncoding != "")
...{
em.BodyEncoding = System.Text.Encoding.GetEncoding(_BodyEncoding);
}
if (_BodyFormat.ToLower() == "html")
...{
em.IsBodyHtml = true;
}
else
...{
em.IsBodyHtml = false;
}
SC.Send(em);
return true;
}
catch (System.Exception E)
...{
return false;
}
}
}
相关文章推荐
- asp.net发送电子邮件的实现(通过一个邮箱向另一个邮箱发送)
- C#asp.net 发送邮件
- c#Asp.Net简单实现发送电子邮件的功用
- Asp.net(c#)发送电子邮件
- Asp.net(c#)发送电子邮件
- c#Asp.Net简单实现发送电子邮件的功用
- ASP.NET(C#)发送电子邮件的方法
- Asp.net(c#)发送电子邮件
- ASP.NET(C#)发送电子邮件的方法
- asp.net c# 定时发送邮件
- asp.net/c# 发送邮件
- 一个过滤特殊字符的函数ASP.NET (C#)
- ASP.NET发送电子邮件
- ASP.NET 2.0中发送电子邮件剖析之一 (转)
- ASP.NET&C#学习笔录5(get和post的区别)
- ASP.NET 2.0发送电子邮件中存在的问题
- 在ASP.NET(C#)中实现在一个文本框输入值后按回车时将光标移到下一个文本框
- Asp.Net发送电子邮件程序
- 推荐一个简单、轻量、功能非常强大的C#/ASP.NET定时任务执行管理器组件–FluentScheduler
- c# asp.net验证您是服务器上"debugger users"组的成员