公司内网邮件发送问题!

shanwa2008 2008-02-27 10:10:08
我引用大侠的代码还是出问题,主要代码如下:
1using System;
2using System.Data;
3using System.Configuration;
4using System.Web;
5using System.Web.Security;
6using System.Web.UI;
7using System.Web.UI.WebControls;
8using System.Web.UI.WebControls.WebParts;
9using System.Web.UI.HtmlControls;
10using System.Net.Mail;
11using System.Net;
12
13public partial class _Default : System.Web.UI.Page
14{
15 protected void Button1_Click(object sender, EventArgs e)
16 {
17 MailMessage message = new MailMessage("support@vs2005.com", "to@domain.com");
18 message.Subject = "hello!";
19 message.Body = "this is a mail from vs2005.com";
20
21 SmtpClient smtp = new SmtpClient("smtp.vs2005.com");
22 smtp.Credentials = new MailCredential("username", "userpassword");
23 smtp.Send(message);
24 }
25}
26
27public class MailCredential : ICredentialsByHost
28{
29 string username = "";
30 string userpwd = "";
31
32 public MailCredential(string un, string pwd)
33 {
34 username = un;
35 userpwd = pwd;
36 }
37
38 ICredentialsByHost Members#region ICredentialsByHost Members
39
40 public NetworkCredential GetCredential(string host, int port, string authenticationType)
41 {
42 NetworkCredential nc = new NetworkCredential(username, userpwd);
43 return nc;
44 }
45
46 #endregion
47}


出错信息如下:
No connection could be made because the target machine actively refused it
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.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Source Error:


Line 25: SmtpClient smtp = new SmtpClient("156.5.80.44");
Line 26: smtp.Credentials = new MailCredential("hong-tao.liu@unilever.com", "P@ssw0rd");
Line 27: smtp.Send(message);
Line 28:
Line 29: }

请问用(c#)vs 2005 asp.net怎么实现企业内网邮件的发送呀?
还请各位大侠多多指点!!
...全文
563 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shanwa2008 2008-02-27
  • 打赏
  • 举报
回复
谢谢大侠的指点!

62,047

社区成员

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

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

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

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