惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
雷峰网
雷峰网
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
P
Proofpoint News Feed
The Cloudflare Blog
D
Docker
大猫的无限游戏
大猫的无限游戏

博客园 - Brendan

[转载]Manually configuring Microsoft Internet Information Services (IIS) IIS与TOMCAT协同工作---在IIS下运行JSP页面 AXIS部署错误解决方案集锦 类的XML序列化(XML Serialization) [翻译]你可以赚钱,但你不能赚时间 Windows 2003 Server配置IIS服务器(ASP, ASP.NET)全功略 Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive 用MS SQL Server事件探查器来跟踪数据库的操作 反反编译工具——Deploy.NET C中获取当前时间的函数 Buffered I/O 与 Non-Buffered I/O性能差异的实例体验 替换函数(Substitution Function) 主定理(Master Theorem) Dynamic Programming之Longest Increasing Subsequence (LIS)问题 ADO.NET数据库连接模块 ASP.NET控件事件丢失的探究 SQLDMO For C#(翻译) 关联(Association)设计中的扇形陷阱(Fan Traps)和断层陷阱(Chasm Traps) 简单并发控制
使用System.Web.Mail发送Mail的错误解决方案
Brendan · 2006-07-14 · via 博客园 - Brendan

        在ASP.NET 1.1上面发送Mail,使用的是System.Web.Mail命名空间,而使用的是STMP Server进行发送。代码非常简单,下面是一个SendMail函数,它接收一封邮件需要的各个要素,然后使用SmtpMail.Send方法发送邮件。

 1 public static void SendMail(string to, string from, string subject, string body, string smtpServer)
 2 {
 3     MailMessage message = new MailMessage();
 4     message.To = to;
 5     message.From = from;
 6     message.Subject = subject;
 7     message.Body = body;
 8 
 9     try
10     {
11         SmtpMail.SmtpServer = smtpServer;
12         SmtpMail.Send(message);
13     }
14     catch(Exception e)
15     {
16     }
17 }

        写这篇文章不是为了说明怎么使用这个函数,因为这个在MSDN上写得已经非常清楚。这个函数用起来看似简单,实际上暗藏玄机。如果你不作任何设置就使用如下的方法来发送mail,你立即会的到一个错误信息:

1 SendMail("sjphappy@126.com""sjphappy@126.com""test""test""127.0.0.1");

错误信息说:"could not access 'CDO.Message' Object"。收到这样的消息,你要做到第一件事就是去查看innerexception的内容,然后根据它来做处理。

如果innerexception='

Exception has been thrown by the target of an invocation',那么你就应该尝试打开inetmgr,到右击"默认SMTP虚拟服务器"->"属性"->"访问"->"中继",然后加入127.0.0.1这个地址就可以解决问题。

如果需要更多这方面的帮助,请访问http://www.systemwebmail.com/