mail发送问题

cqnetboy 2003-09-14 07:42:51
......

MailMessage mailObj = new MailMessage();
mailObj.From = "netboy@junnet.com.cn";
mailObj.To = "netboy@junnet.com.cn";
mailObj.Subject = "title";
mailObj.Body = "body";
mailObj.Priority = MailPriority.High;
mailObj.Attachments.Add(new MailAttachment("c://chenhu2//chdhzcm.chh"));
SmtpMail.Send(mailObj);

......

报错说:“SendUsing”配置值无效。
...全文
92 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangzs8896 2003-09-15
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;//邮件使用
using System.Windows.Forms; //Messagebox使用;

namespace zzs_test
{
/// <summary>
/// Mail 的摘要说明。
/// </summary>
public class Mail : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.DropDownList sender_ddl;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Button btn_send;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
// Response.Write("test: " +ConfigurationSettings.AppSettings["test"]);
// Response.End();
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btn_send.Click += new System.EventHandler(this.btn_send_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btn_send_Click(object sender, System.EventArgs e)//发送
{
MailMessage Message=new MailMessage();
//Message.From="zhangzs@tpco.com.cn";
Message.From=sender_ddl.SelectedItem.Value+"@tpco.com.cn";
Message.To=TextBox1.Text;
Message.Subject=TextBox3.Text;
Message.Body=TextBox2.Text;
Message.BodyFormat=MailFormat.Text;
Message.Priority=MailPriority.Low;

string[] ServerPool = new string[2];
ServerPool[0]="dns.tpco.com.cn";
//ServerPool[1]="smtp.163.com";
SmtpMail.SmtpServer=ServerPool[0];
SmtpMail.Send(Message);

MessageBox.Show("成功发送到 "+ TextBox1.Text, "C#邮件",MessageBoxButtons.OK,
MessageBoxIcon.Information,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification);
}
}
}
cqnetboy 2003-09-14
  • 打赏
  • 举报
回复
哪位能帮忙说说是怎么回事,如果有可以有的email发送代码可以给小弟一个。c#的,谢谢!!
netboy@junnet.com.cn
cqnetboy 2003-09-14
  • 打赏
  • 举报
回复
mailObj.SmtpServer="邮件服务器"; //dns.junnet.com.cn?
--------------->>
SendMail.aspx.cs(65): “System.Web.Mail.MailMessage”并不包含对“SmtpServer”的定义
????
zhangzs8896 2003-09-14
  • 打赏
  • 举报
回复
MailMessage mailObj = new MailMessage();
mailObj.From = "netboy@junnet.com.cn";
mailObj.To = "netboy@junnet.com.cn";
mailObj.Subject = "title";
mailObj.Body = "body";
mailObj.Priority = MailPriority.High;
mailObj.Attachments.Add(new MailAttachment("c://chenhu2//chdhzcm.chh"));
SmtpMail.Send(mailObj);
-------------->
MailMessage mailObj = new MailMessage();
mailObj.From = "netboy@junnet.com.cn";
mailObj.To = "netboy@junnet.com.cn";
mailObj.Subject = "title";
mailObj.Body = "body";
mailObj.Priority = MailPriority.High;
mailObj.SmtpServer="邮件服务器"; //dns.junnet.com.cn?
SmtpMail.Send(mailObj);
cqnetboy 2003-09-14
  • 打赏
  • 举报
回复

堆栈跟踪:


[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) +113
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1846
System.Web.Mail.SmtpMail.Send(MailMessage message) +153
J_Net_v2.SendMail.btSendMail_Click(Object sender, EventArgs e) in c:\documents and settings\netboy\vswebcache\netboy_tablepc_83\sendmail.aspx.cs:62
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() +1277


cnlamar 2003-09-14
  • 打赏
  • 举报
回复
gz

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧