请检查我的发邮件的代码为什么错误?

nobody_am 2005-10-25 05:30:27
MailMessage mail = new MailMessage();
mail.To = "ming3232@21cn.com";
mail.From = "ming0987@163.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "ming0987"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); //set your password here

SmtpMail.SmtpServer = "smtp.163.com"; //your real server goes here

SmtpMail.Send( mail );


================错误是:==================================================
异常详细信息: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.

源错误:


行 62: SmtpMail.SmtpServer = "smtp.163.com"; //your real server goes here
行 63:
行 64: SmtpMail.Send( mail );
行 65: }
行 66: }


源文件: c:\inetpub\wwwroot\mailtest\webform1.aspx.cs 行: 64

堆栈跟踪:


[COMException (0x80040213): The transport failed to connect to the server.
]

[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) +1846
System.Web.Mail.SmtpMail.Send(MailMessage message) +153
MailTest.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\mailtest\webform1.aspx.cs:64
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



...全文
138 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
nobody_am 2005-10-27
  • 打赏
  • 举报
回复
jmail 也发不出去,错误如下:

---
System.Runtime.InteropServices.COMException: The message was undeliverable. All servers failed to receive the message
nobody_am 2005-10-26
  • 打赏
  • 举报
回复
果然vs2003没有System.Net.Mail.MailMessage 命名空间。
nobody_am 2005-10-26
  • 打赏
  • 举报
回复
貌似 kele8018(怀怀) 提供的代码是vs2005版才支持吧,我先看看vs2003能不能支持。
tanyuqiong 2005-10-26
  • 打赏
  • 举报
回复
用jmail试试...
nobody_am 2005-10-26
  • 打赏
  • 举报
回复
自己up,你们在.net framework1.1上,怎么发web邮件?
kele8018 2005-10-25
  • 打赏
  • 举报
回复
string Send="ming0987@163.com";
string SendTo="ming3232@21cn.com";
System.Net.Mail.MailMessage Smtpmail = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress MASend = new System.Net.Mail.MailAddress(Send);
Smtpmail.From = MASend;
Smtpmail.To.Add(SendTo);
Smtpmail.Subject = "this is a test email";
Smtpmail.Body = "Some text goes here";
System.Net.Mail.SmtpClient SendSmtp = new System.Net.Mail.SmtpClient("smtp.163.com", 25);
SendSmtp.Credentials = new System.Net.NetworkCredential("ming0987", "123456 ");
SendSmtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
SendSmtp.Send(Smtpmail);
nobody_am 2005-10-25
  • 打赏
  • 举报
回复
用户名 ming0987 密码123456
肯定是正确有效的

mail message是对cdo的封装。
jmail需要第三方的库吗?
sunzhong2003 2005-10-25
  • 打赏
  • 举报
回复
楼主肯定是没给用户名和密码
sunzhong2003 2005-10-25
  • 打赏
  • 举报
回复
可以的,我在www.semhoo.com上试过,只不过要用有用户的发,可以用JMAIL或者CDO发信
nobody_am 2005-10-25
  • 打赏
  • 举报
回复
To foxconn_nich:
JavaMail可以用这个smtp server发邮件,我试过了。
另外请问那个免费邮件服务器可以发?
foxconn_nich 2005-10-25
  • 打赏
  • 举报
回复
SmtpMail.SmtpServer = "smtp.163.com"

这个Smtp邮件服务器不行

62,073

社区成员

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

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

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

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