日期:2014-05-18 浏览次数:20361 次
try { TestMail t = new TestMail("aa@163.com", "内容", "标题"); int i = cm.ExecuteNonQuery(); if (t.sengmill_net() & i > 0) { Response.Write("<script language=javascript>alert('投诉提交成功')</script>"); } redirect(); }
using System; using System.Web.Mail; namespace midlink_healthcare { public class TestMail { string tb_from; string tb_to; string tb_mailBody; string tb_smtpserver; string tb_body; string tb_sub; public TestMail(string to ,string body,string sub) { tb_to=to.Trim(); //tb_name=name.Trim(); tb_body=body.Trim(); tb_sub=sub.Trim(); } public void sengmill_net() { tb_from= "xxx@xxxx.com ";//你使用的邮箱名字 tb_mailBody=tb_body; tb_smtpserver= "xxx.xx.xxx.xxx ";//你使用的邮件服务器的ip地址 System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage(); mailmsg.From = tb_from; mailmsg.To = tb_to; mailmsg.Body = tb_mailBody; mailmsg.Subject =tb_sub; mailmsg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 "); //是否需要验证,一般是要的 mailmsg.Fields.Add ( "http://schemas.microsoft.com/cdo/configuration/sendusername ", "xxxxx "); //自己邮箱的用户名 mailmsg.Fields.Add( "http:/