C#发email发不出去

michelle_weimei 2009-01-06 08:52:25
private System.Web.Mail.MailMessage m_Mail;

m_Mail=new MailMessage();

m_Mail.From="Michelle.Wei@cnweidmuller.com";

m_Mail.To="Michelle.Wei@cnweidmuller.com";
m_Mail.Subject="test";

m_Mail.BodyFormat=MailFormat.Html;

m_Mail.Body="hello!!!";
SmtpMail.SmtpServer="srvcn015.weidmueller.com";

SmtpMail.Send(m_Mail);

错误信息是:
The message could not be sent to the SMTP server. The transport error code was 0x800ccc15. The server response was not available
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: The message could not be sent to the SMTP server. The transport error code was 0x800ccc15. The server response was not available

Source Error:


Line 80: SmtpMail.SmtpServer="srvcn015.weidmueller.com";
Line 81:
Line 82: SmtpMail.Send(m_Mail);
Line 83:
Line 84: //Label3.Text="发送成功";


Source File: c:\inetpub\wwwroot\webapplication1\webform3.aspx.cs Line: 82

Stack Trace:


[COMException (0x80040211): The message could not be sent to the SMTP server. The transport error code was 0x800ccc15. The server response was not available
]

[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.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29
System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj, String methodName, Object[] args)
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
System.Web.Mail.SmtpMail.Send(MailMessage message)
WebApplication1.WebForm3.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication1\webform3.aspx.cs:82
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()


请问是什么问题啊?
...全文
289 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
michelle_weimei 2009-01-08
  • 打赏
  • 举报
回复
解决了,原来是我的杀毒软件给屏蔽了。谢谢大家!
michelle_weimei 2009-01-06
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 zhouxing_24 的回复:]
SmtpMail,这个东西需要你本地有Smtp服务器的,你本地没有这个Smtp服务器所以没有用的!
介绍给你一个Jmail的吧,http://blog.csdn.net/zhouxing_24/archive/2008/12/30/3650579.aspx
关于这个JMAIL类你可以到网络上下载!
[/Quote]
还是不行,错误信息如下:

[COMException (0x8000ffff): The message was undeliverable. All servers failed to receive the message]
jmail.MessageClass.Send(String mailServer, Boolean enque) +0
WebApplication1.WebForm3.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication1\webform3.aspx.cs:69
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()


zhouxing_24 2009-01-06
  • 打赏
  • 举报
回复
SmtpMail,这个东西需要你本地有Smtp服务器的,你本地没有这个Smtp服务器所以没有用的!
介绍给你一个Jmail的吧,http://blog.csdn.net/zhouxing_24/archive/2008/12/30/3650579.aspx
关于这个JMAIL类你可以到网络上下载!
lovehongyun 2009-01-06
  • 打赏
  • 举报
回复
验证没有通过,是.net 2.0用下面的代码发即可.(System.Net.Mail命名空间的)


SmtpClient smtp = new SmtpClient("srvcn015.weidmueller.com");
smtp.Credentials = new System.Net.NetworkCredential(发件邮箱的用户名, 密码);
MailMessage mes = new MailMessage();

mes.From = new MailAddress("Michelle.Wei@cnweidmuller.com");
mes.To.Add("要发给谁");

mes.Subject = "主题";
mes.Body = "hello!";
mes.IsBodyHtml = true;

smtp.Send(mes);
cyz9977 2009-01-06
  • 打赏
  • 举报
回复
如果是你們公司的那就填你們公司的郵件server
然后用你自己的帳號密碼
michelle_weimei 2009-01-06
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 stupid_boy2007 的回复:]
SmtpMail.SmtpServer="srvcn015.weidmueller.com";

请问你的邮件是不是通过网络上的服务器转发的啊!看你的smtp服务器地址对不!像163的是smtp.163.com
还有就是授权,用户名密码..你网上搜一下,有示例

如果是本地iis中,我没用过!
[/Quote]
我们公司用的是exchange server,这个支持smtp吗?
庚武讲堂 2009-01-06
  • 打赏
  • 举报
回复
SmtpMail.SmtpServer="srvcn015.weidmueller.com";

请问你的邮件是不是通过网络上的服务器转发的啊!看你的smtp服务器地址对不!像163的是smtp.163.com
还有就是授权,用户名密码..你网上搜一下,有示例

如果是本地iis中,我没用过!
michelle_weimei 2009-01-06
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 designonline 的回复:]
查查你的iis里有没有安装smtp
[/Quote]
已经装了。如果SmtpMail.SmtpServer="localhost"; 那么测试就可以成功了。在:\Inetpub\mailroot\Queue 下面就可以看到我发的邮件。问题是我要发到我们公司的邮件服务器上去。公司的人才能看到我发的邮件啊。
michelle_weimei 2009-01-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xfreyes 的回复:]
你的邮件服务器不能用SmtpMail.SmtpServer="srvcn015.weidmueller.com";
[/Quote]

那应该怎么写?
designonline 2009-01-06
  • 打赏
  • 举报
回复
查查你的iis里有没有安装smtp
designonline 2009-01-06
  • 打赏
  • 举报
回复
SmtpMail 怀疑没有安装好.
或者使用jmail组件测试一下
空空空 2009-01-06
  • 打赏
  • 举报
回复
防火墙是否阻止了大量发邮件端口
xfreyes 2009-01-06
  • 打赏
  • 举报
回复
你的邮件服务器不能用SmtpMail.SmtpServer="srvcn015.weidmueller.com";

62,268

社区成员

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

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

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

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