关于ASP.NET中EMAIL发送的问题!急!在线等待!
请高手帮我 一下问什么会有这个问题,如何解决
这是一个类
using System;
using System.Web.Mail;
namespace WebA
{
/// <summary>
/// Mailsend 的摘要说明。
/// </summary>
public class Email
{
private MailMessage newMail;
public Email(string txtTo,string txtMessage)
{
newMail=new MailMessage();
newMail.From="TianHeng@TianHeng.com";
newMail.To=txtTo;
newMail.Subject="天恒购书网站密码取回信!";
newMail.Body=txtMessage;
newMail.BodyFormat=System.Web.Mail.MailFormat.Html;
}
public void SendEmail()
{
SmtpMail.Send(newMail);
}
}
}
----------------------------------------------------------------------
这是发送
private void Button2_Click(object sender, System.EventArgs e)
{
Email my=new Email(TextBox2.Text,TextBox3.Text);
my.SendEmail();
}
-------------------------------------------------
下面是出现的问题
Server Error in '/WebA' Application.
--------------------------------------------------------------------------------
“SendUsing”配置值无效。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: “SendUsing”配置值无效。
Source Error:
Line 21: public void SendEmail()
Line 22: {
Line 23: SmtpMail.Send(newMail);
Line 24: }
Line 25:
Source File: c:\inetpub\wwwroot\weba\mailsend.cs Line: 23
Stack Trace:
[COMException (0x80040220): “SendUsing”配置值无效。
]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +111
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1516
System.Web.Mail.SmtpMail.Send(MailMessage message) +49
WebA.Email.SendEmail() in c:\inetpub\wwwroot\weba\mailsend.cs:23
WebA.mytest.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\weba\mytest.aspx.cs:56
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263