private void Submit1_ServerClick(object sender, System.EventArgs e)
{
SendMail (sender, e);
}
public void SendMail (Object Obj, EventArgs E)
{
System.Web.Mail.MailMessage myMail=new System.Web.Mail.MailMessage();
myMail.From = "[email protected]";
myMail.To = "[email protected]";
myMail.Subject = "Subject Of the Mail";
myMail.Body = "Body of the Mail";
myMail.BodyFormat = System.Web.Mail.MailFormat.Html;
myMail.Priority = System.Web.Mail.MailPriority.High;
System.Web.Mail.SmtpMail.Send(myMail);
}
System.Runtime.InteropServices.COMException: “SendUsing”配置值无效。 System.Web.Mail.SmtpMail.Send(myMail);
<%@Import Namespace="System.Web.Mail" %>我写了using System.Web.Mail;也写了。
为什么 回出现上面的问题???
{
SendMail (sender, e);
}
public void SendMail (Object Obj, EventArgs E)
{
System.Web.Mail.MailMessage myMail=new System.Web.Mail.MailMessage();
myMail.From = "[email protected]";
myMail.To = "[email protected]";
myMail.Subject = "Subject Of the Mail";
myMail.Body = "Body of the Mail";
myMail.BodyFormat = System.Web.Mail.MailFormat.Html;
myMail.Priority = System.Web.Mail.MailPriority.High;
System.Web.Mail.SmtpMail.Send(myMail);
}
System.Runtime.InteropServices.COMException: “SendUsing”配置值无效。 System.Web.Mail.SmtpMail.Send(myMail);
<%@Import Namespace="System.Web.Mail" %>我写了using System.Web.Mail;也写了。
为什么 回出现上面的问题???
首先你要获得认证啊..........SmtpMail.SmtpServer="smtp.sina.com.cn";//发送服务器
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");//认证
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","your_name");//用户名
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","your_password");//密码
System.Web.Mail.SmtpMail.SmtpServer = 服务器地址;
myMail.From = "[email protected]";
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","myaccount");
这样,
否则好象不行
wangyinet(卢佳宜)