关于ASP。NET发送HTML格式的邮件
2006-12-27 13:37
411 查看
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;
public partial class sendmail : System.Web.UI.Page
{
private static string smtpserver="smtp.126.com";
private static string serveremail="z***g758@126.com";
private static string serverpass="*6****5";
private static int port=25;
private static bool ssl=false;
public static bool sendgmail(string mailto,string subject,string body)
{
SmtpClient mail=new SmtpClient(smtpserver,port);
mail.UseDefaultCredentials=true;
mail.Credentials=new System.Net.NetworkCredential(serveremail,serverpass);
mail.DeliveryMethod=SmtpDeliveryMethod.Network;
mail.EnableSsl=ssl;
MailMessage message=new MailMessage(serveremail,mailto,subject,body);
message.SubjectEncoding=System.Text.Encoding.GetEncoding("gb2312");
message.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");
message.IsBodyHtml = true;
try
{
mail.Send(message);
return true;
}
catch(Exception e)
{
System.Web.HttpContext.Current.Response.Write(e.Message);
return false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void send_Click(object sender, EventArgs e)
{
sendgmail(to.Text, subject.Text, content.Text);
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;
public partial class sendmail : System.Web.UI.Page
{
private static string smtpserver="smtp.126.com";
private static string serveremail="z***g758@126.com";
private static string serverpass="*6****5";
private static int port=25;
private static bool ssl=false;
public static bool sendgmail(string mailto,string subject,string body)
{
SmtpClient mail=new SmtpClient(smtpserver,port);
mail.UseDefaultCredentials=true;
mail.Credentials=new System.Net.NetworkCredential(serveremail,serverpass);
mail.DeliveryMethod=SmtpDeliveryMethod.Network;
mail.EnableSsl=ssl;
MailMessage message=new MailMessage(serveremail,mailto,subject,body);
message.SubjectEncoding=System.Text.Encoding.GetEncoding("gb2312");
message.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");
message.IsBodyHtml = true;
try
{
mail.Send(message);
return true;
}
catch(Exception e)
{
System.Web.HttpContext.Current.Response.Write(e.Message);
return false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void send_Click(object sender, EventArgs e)
{
sendgmail(to.Text, subject.Text, content.Text);
}
}
相关文章推荐
- asp.net 发送HTML格式邮件及发送Html模版邮件
- C#利用System.Net发送邮件(带 抄送、密送、附件、html格式的邮件)
- 关于asp.net 下发送邮件 未能访问"CDO.Message"对象 问题(1)
- 关于asp.net 发送邮件问题
- 用ASP发送HTML格式的邮件
- c#利用system.net发送html格式邮件
- 用ASP程序发送HTML格式邮件的问题!
- asp.net关于发送邮件问题
- 关于ASP.NET中使用SMTP server发送邮件的IIS配置
- 如何通过 ASP 来发送带附件、格式为 HTML 的邮件?下面提供了一个例程.
- 如何用ASP发送html格式的邮件?
- asp.net发送邮件带格式(本demo发送验证码)
- asp.net代码发送邮件方法(二)
- Linux环境下sendmail发送html格式正文及csv格式附件邮件
- ASP.NET MVC通过发送邮件激活注册用户
- asp.net 发送邮件
- asp.net实现发送邮件
- 用JavaMail发送HTML格式的邮件
- 【Vegas原创】asp/html页面作为邮件正文发送
- jenkins html 发送邮件格式