- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
无法在 Windows Vista Business 中测试从 .NET 代码发送电子邮件。
我正在编写代码,一旦经过验证,我将迁移到 SSIS 包。该代码用于通过电子邮件向收件人列表发送错误消息。
代码如下,但是当我执行代码时出现异常。
我创建了一个简单的类来进行邮件发送...设计可能会更好,我正在测试功能,然后再实现更强大的功能、方法等。
namespace LabDemos
{
class Program
{
static void Main(string[] args)
{
Mailer m = new Mailer();
m.test();
}
}
}
namespace LabDemos
{
class MyMailer
{
List<string> _to = new List<string>();
List<string> _cc = new List<string>();
List<string> _bcc = new List<string>();
String _msgFrom = "";
String _msgSubject = "";
String _msgBody = "";
public void test(){
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@domain.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is a sample body";
mail.IsBodyHtml = false;
//send the message
SmtpClient smtp = new SmtpClient();
smtp.Host = "emailservername";
smtp.Port = 25;
smtp.UseDefaultCredentials = true;
smtp.Send(mail);
}
}
异常消息
Inner Exception
{"Unable to read data from the transport connection: net_io_connectionclosed."}
Stack Trace
" at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)\r\n at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)\r\n at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)\r\n at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)\r\n at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)\r\n at System.Net.Mail.SmtpClient.GetConnection()\r\n at System.Net.Mail.SmtpClient.Send(MailMessage message)"
Outer Exception
System.Net.Mail.SmtpException was unhandled
Message="Failure sending mail."
Source="System"
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at LabDemos.Mailer.test() in C:\Users\username\Documents\Visual Studio 2008\Projects\LabDemos\LabDemos\Mailer.cs:line 40
at LabDemos.Program.Main(String[] args) in C:\Users\username\Documents\Visual Studio 2008\Projects\LabDemos\LabDemos\Program.cs:line 48
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.IOException
Message="Unable to read data from the transport connection: net_io_connectionclosed."
Source="System"
StackTrace:
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException:
最佳答案
有几种情况会导致此问题,以下是我发现的一些情况。问题:您提到“Exchange”——这是一个交换服务器吗?主机是否需要身份验证(也许您需要向客户端添加身份验证)?我首先尝试做的是将主机分配给静态 IP 地址而不是主机名,以查看它是否首先有效。如果是,则很可能是 DNS 映射有问题。
If you are running your exchange server with Virtualization, you need to configure the SmtpClient to the host IP of the Virtual Server, not the physical hosting server name or IP. Right click on Default SMTP virtual server, select Properties, then go to Access tab, click Relay then add the IP address of the computer that send SMTP request to the SMTP server. (ASP.net site)
如果这不起作用,那是因为服务器阻止您发送 SMTP 数据包。您需要确保将发送 SMTP 消息的邮箱添加到 SMTP 服务器。这是通过 IIS 的身份验证选项卡完成的。
我还要指出的是,您应该处理邮件客户端,或者在“using”语句中使用客户端。这将确保将“QUIT”发送到服务器并正常关闭连接。
using(SmtpClient smtp = new SmtpClient())
{
smtp.Host = "emailservername";
smtp.Port = 25;
smtp.UseDefaultCredentials = true;
smtp.Send(mail)
}
关于c# - "Unable to read data from the transport connection: net_io_connectionclosed."- Windows Vista 商业版和 SMTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1143846/
我目前正在使用 C# 和 WPF 在 .Net 4.0 中开发一个商业 Windows 应用程序(封闭源代码,免费演示,可用功能有限)。我现在正在寻找具有以下功能的 map 库: 全局在线 map 和
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
作为项目的一部分,我需要评估一些商业 C# 图表组件。我正在寻找功能丰富的组件,这些组件支持缩放/平移,可以处理实时更新,甚至可以为双击某个点等事件生成事件。 如果我需要从 WinForms 迁移到
这个问题在这里已经有了答案: Best solution to protect PHP code without encryption (11 个答案) 关闭 2 年前。 我正在考虑制作一个商业应用
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
抱歉这个愚蠢的问题,因为我是新手。如果我想构建一个商业 Windows 应用程序(我将以 $ 的价格出售),我在嵌入式数据存储方面有哪些选择?我会使用 MSDE 吗?这是我要与我的应用程序捆绑在一起的
我喜欢在 Android 商业(付费)应用程序中使用自定义字体 FiraSans。除了字体目录位置中的 SIL Open Font License.txt ..我是否需要强制添加其他任何内容,例如:
由于许可问题,我们公司几乎禁止我们在我们的商业产品中使用开源库。我们目前正在寻找可以读取和解析 CSV 文件的商业 .NET 库 - 有人有任何想法吗? 就功能而言,我确实需要能够将 CSV 文件读入
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 8 年前。 Improve
目前我希望将 paypal 支付集成到我的应用程序中,所以我下载了 django-paypal (dcramer) 以使用 paypal 沙箱对其进行测试。我尝试将 WPP express check
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
我正在组装我的第一个商业 PHP 应用程序,它并不大,因为我仍在热切地学习 PHP :) 现在我仍处于规划我的应用程序的概念阶段,但我一直遇到一个问题,该应用程序应该由我的客户在他们自己的服务器上自行
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 8 年前。 Improve
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我的网站是使用 php 文件构建的。我在这些文件中使用了商业 secret 算法,我的数据库根密码也存储在这些 php 文件中。我的数据库用于存储许多客户的私有(private)医疗数据。 这是否被认
我知道如何在 map 上设置点击事件,并且在点击随机位置时效果很好。但是当我点击一个商业地点时,谷歌地图会显示包含商业信息的气球,但不会向我的 JavaScript 引发点击事件。 您可以在此地理编码
有时我必须对 Java 代码做一些分析工作,我想知道为什么我应该让我的老板在商业分析器中进行调查,而不是只使用 Netbeans 或 JConsole 中的分析器? 值得投资的 killer 级功能是
我使用 Airbrake 通知我 Spree Commerce 商店中的错误。现在我想使用 spree 的 API,当我尝试发布到 http://localhost:3000/api/products
为了实现基于 Windows 的翻页应用程序,我需要能够将大量 PDF 页面转换为高质量的 JPG,而不仅仅是缩略图。 目的是为此实现最佳质量/文件大小,类似于 Photoshops Save for
我是一名优秀的程序员,十分优秀!