以下为错误信息:
。
óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.Runtime.InteropServices.COMException: óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
源错误:行 122: SmtpMail.SmtpServer = "smtp.163.com";
行 123: //发送
行 124: SmtpMail.Send(msg);
行 125: //Response.Write("<script language='javascript'>alert('注册成功');window.location='.. /default.aspx'</script>");
行 126: }
源文件: f:\usr\cn1c033\product_tuijian.aspx.cs 行: 124堆栈跟踪:[COMException (0x80040211): óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
][TargetInvocationException: 调用的目标发生了异常。]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +436
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +72[HttpException (0x80004005): óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +119
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1955
System.Web.Mail.SmtpMail.Send(MailMessage message) +131
product_tuijian.Button1_Click(Object sender, EventArgs e) in f:\usr\cn1c033\product_tuijian.aspx.cs:124
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746以一回为C#原码
。
óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.Runtime.InteropServices.COMException: óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
源错误:行 122: SmtpMail.SmtpServer = "smtp.163.com";
行 123: //发送
行 124: SmtpMail.Send(msg);
行 125: //Response.Write("<script language='javascript'>alert('注册成功');window.location='.. /default.aspx'</script>");
行 126: }
源文件: f:\usr\cn1c033\product_tuijian.aspx.cs 行: 124堆栈跟踪:[COMException (0x80040211): óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
][TargetInvocationException: 调用的目标发生了异常。]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +436
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +72[HttpException (0x80004005): óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +119
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1955
System.Web.Mail.SmtpMail.Send(MailMessage message) +131
product_tuijian.Button1_Click(Object sender, EventArgs e) in f:\usr\cn1c033\product_tuijian.aspx.cs:124
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746以一回为C#原码
using System.Data;
using System.Configuration;
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.Web.Mail;using System.Data.SqlClient;public partial class product_tuijian : System.Web.UI.Page
{
WebFunction bc = new WebFunction();
string curPage;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dataGridBind();
}
} public void dataGridBind()
{
string cpok = "";
string p_id = Request.QueryString["id"].ToString();
string p_name = "";
SqlDataReader sdr = WebFunction.dataReader("select top 1 * from [glcity_product] where id='" + p_id + "'");
if (sdr.Read())
{
this.p_Id.Value = p_id;
p_name = sdr["p_name"].ToString();
this.tuijian.Text = "<a href=product_open.aspx?id=" + p_id + " target=_blank>" + sdr["p_name"].ToString() + "</a>";
}
else
{
this.p_Id.Value = "";
this.tuijian.Text = "";
}
WebFunction.closeDataReader(ref sdr);
this.txtContent.Text = "你好,我在【zyxqgg.com】网站上看到一件不错的商品【" + p_name + "】,我想你也会非常喜欢,就推荐给你瞧瞧,有兴趣就去看看吧~~ 网址是:http://www.0395.net.cn/product_open.asp?id=" + p_id;
}
protected void Button1_Click(object sender, EventArgs e)
{
//string p_ID = e.CommandArgument.ToString(); string p_ID = this.p_Id.Value; string ToName = this.ToName.Text;
string ToEmail = this.ToEmail.Text;
string FormName = this.FormName.Text;
string FormEmail = this.FormEmail.Text;
string txtContent = this.txtContent.Text; /*
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = this.FormEmail.Text.Trim();
mailmsg.To = this.ToEmail.Text.Trim();
mailmsg.Body = this.txtContent.Text.Trim();
mailmsg.Subject = "来自 " + this.FormName.Text.Trim() + " 朋友给您推荐的商品"; //标题
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "glcity");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "*****");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = "mail.163.com";//设置smtp服务器
System.Web.Mail.SmtpMail.Send(mailmsg);
*/ /*
MailMessage mailmsg = new MailMessage();
mailmsg.From = this.FormEmail.Text.Trim();
mailmsg.To = this.ToEmail.Text.Trim();
mailmsg.Body = this.txtContent.Text.Trim();
mailmsg.Subject = "来自 " + this.FormName.Text.Trim() + " 朋友给您推荐的商品"; //标题
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "glcity2008");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "******");
//自己邮箱的密码
*/
/*
mailmsg.Fields.Add(CdoConfiguration.cdoSMTPAuthenticate, "1");
mailmsg.Fields.Add(CdoConfiguration.cdoSendUserName, "glcity168"); //用户名
mailmsg.Fields.Add(CdoConfiguration.cdoSendPassword, "******"); //密码
*/
/*
SmtpMail.SmtpServer = "smtp.126.com";//设置smtp服务器
SmtpMail.Send(mailmsg);
*/ MailMessage msg = new MailMessage();
//发送方地址(如[email protected])
msg.From = FormEmail;
//接收方地址(如[email protected])
msg.To = ToEmail;
//正文内容类型
msg.BodyFormat = MailFormat.Html;
//正文内容编码
msg.BodyEncoding = System.Text.Encoding.Default;
//主题
msg.Subject = this.FormName.Text.Trim() + " 您好!" + this.FormName.Text.Trim() + " 朋友给您推荐的商品";
//内容
msg.Body = txtContent;
//设置为需要用户验证
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置验证用户名
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "glcity");
//设置验证密码
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "******");
//邮件服务器地址(如smtp.163.com)
SmtpMail.SmtpServer = "smtp.163.com";
//发送
SmtpMail.Send(msg);
//Response.Write("<script language='javascript'>alert('注册成功');window.location='.. /default.aspx'</script>");
} //关闭窗口
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<script language='javascript'>window.close();</script>");
return;
}}
using System.Data;
using System.Configuration;
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;
using System.Net.Mail; public partial class _Default : System.Web.UI.Page
...{
int i = 0;
protected void Page_Load(object sender, EventArgs e)
...{
}
protected void Button1_Click(object sender, EventArgs e)
...{
string s_from = TextBox1.Text.Trim().ToString();//发件人
string s_to = TextBox2.Text.Trim().ToString();//收件人
string s_body = TextBox4.Text.Trim().ToString();//邮件内容
s_body = s_body.Replace(" ", " <br/>");
s_body = s_body.Replace(" ", " <br/>");
s_body = s_body.Replace(" ", " "); int i = s_from.IndexOf("@");
string username = s_from.Substring(0, i);
MailAddress from = new MailAddress(s_from);
MailAddress to = new MailAddress(s_to);
MailMessage mailobj = new MailMessage(from, to);
mailobj.Subject = TextBox3.Text.Trim().ToString();//邮件标题
mailobj.Body = s_body;
mailobj.IsBodyHtml = true;
mailobj.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
mailobj.Priority = MailPriority.High; if (FileUpload1.PostedFile.ContentLength > 0)//附件
...{
mailobj.Attachments.Add(new Attachment(FileUpload1.PostedFile.FileName));
} SmtpClient smtp = new SmtpClient("smtp.qq.com"); //smtp服务器为smtp.qq.com
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("270332289","f5sd1e"); //用户名为270332289,密码为f5sd1e
smtp.DeliveryMethod = SmtpDeliveryMethod.Network; try
...{
smtp.Send(mailobj);
Response.Write("ok!"); }
catch
...{
Response.Write("sorry!");
}
}
}
如:from="[email protected]";
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "user7788");另外,网易不支持新注册用户使用pop3和smtp
谢谢!!!
{
Encoding enc = Encoding.UTF8;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(FromAddress, ToAddress);
mail.Subject = MailName;
mail.SubjectEncoding = enc;
mail.Body = MyInfo;
SmtpClient smpt = new SmtpClient();
smpt.Host = SubAddress;
mail.IsBodyHtml = true;
smpt.Send(mail);
}
{
//string p_ID = e.CommandArgument.ToString(); string p_ID = this.p_Id.Value; string ToName = this.ToName.Text;
string ToEmail = this.ToEmail.Text;
string FormName = this.FormName.Text;
string FormEmail = this.FormEmail.Text;
string txtContent = this.txtContent.Text; MailMessage msg = new MailMessage();
//发送方地址(如[email protected])
//msg.From = FormEmail;
msg.From = "[email protected]";
//接收方地址(如[email protected])
msg.To = ToEmail;
//正文内容类型
msg.BodyFormat = MailFormat.Html;
//正文内容编码
msg.BodyEncoding = System.Text.Encoding.Default;
//主题
msg.Subject = this.ToName.Text.Trim() + " 您好!" + this.FormName.Text.Trim() + " 朋友给您推荐的商品";
//内容
msg.Body = txtContent;
//设置为需要用户验证
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置验证用户名
//msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "glcity168");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "glcity168");
//设置验证密码
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "******");
//邮件服务器地址(如smtp.163.com)
SmtpMail.SmtpServer = "smtp.sina.com";
//发送
SmtpMail.Send(msg);
//Response.Write("<script language='javascript'>alert('注册成功');window.location='.. /default.aspx'</script>");
}