发送Email问题?
xuya 2003-04-21 06:00:22 我按书上写了以下代码:
《---------------------------
<%@ import namespace="System.Web.Mail" %>
<!--#include file=html.inc-->
<script language="vb" runat="server">
sub btnsend_click(sender as object ,e as eventargs)
dim mail as MailMessage=new MailMessage()
'定义mail的各个域的信息
mail.to=txtmailto.text
mail.from=txtmailfrom.text
mail.subject=txtmailsubject.text
mail.cc=txtmailcc.text
mail.bcc=txtmailbcc.text
if rdomailpriority.selecteditem.value="high" then
mail.priority=mailpriority.high
elseif rdomailpriority.selecteditem.value="nomal" then
mail.priority=mailpriority.normal
else
mail.priority=mailpriority.low
end if
if rdomailbodyformat.selecteditem.value="html" then
mail.bodyformat=mailformat.html
else
mail.bodyformat=mailformat.text
end if
mail.body=txtmailbody.text
'增加附件
dim filename as string=attachfile.postedfile.filename
dim mailattach as mailattachment
if filename<>"" then
mailattach=new mailattachment(filename)
mail.attachments.add(mailattach)
end if
'发送邮件
if mail.to<>nothing then
smtpmail.send(mail)
lblmessage.text="邮件已经发送成功!"
else
lblmessage.text="收件人地址不能为空!"
end if
end sub
</script>
---------------------------------------------
运行后有以下出错信息:
-------------------------------------》
“/Email”应用程序中的服务器错误。
--------------------------------------------------------------------------------
“SendUsing”配置值无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Runtime.InteropServices.COMException: “SendUsing”配置值无效。
源错误:
行 33: '发送邮件
行 34: if mail.to<>nothing then
行 35: smtpmail.send(mail)
行 36: lblmessage.text="邮件已经发送成功!"
行 37: else
源文件: K:\wwwroot\Email\sendMail.aspx 行: 35
堆栈跟踪:
[COMException (0x80040220): “SendUsing”配置值无效。
]
[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 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): 未能访问“CDO.Message”对象。]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +112
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1516
System.Web.Mail.SmtpMail.Send(MailMessage message) +49
ASP.sendMail_aspx.btnsend_click(Object sender, EventArgs e) in K:\wwwroot\Email\sendMail.aspx:35
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
--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.288; ASP.NET 版本:1.0.3705.288
不知道这是怎么回事,是不是要在iis里进行配置?还是其他什么原因?高手指教啊!