【问题标题】:Transport errors due to class location? (SMTP)上课地点导致的交通错误? (SMTP)
【发布时间】:2010-12-17 04:33:34
【问题描述】:

使用集成身份验证 + 模拟的 ASP.NET 2.0 内部(内部网)Web 应用程序。在开发服务器(类所在的位置)上开发并发布到生产 Intranet 服务器。请多多包涵,我不是 .NET 开发人员!由于 Exchange 服务器移动和升级,具有邮件功能的旧应用程序损坏。我在开发服务器的类文件中找到了 SMTP 代码。问题是,如果我在本地调用它作为给定页面代码后面的函数(邮件功能有效),则此代码工作正常,但如果我尝试调用与公共类相同的代码,则会收到以下错误:

The transport failed to connect to the server.

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 transport failed to connect to the server.


Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


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

[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 bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +2501616
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +72

[HttpException (0x80004005): The transport failed to connect to the server.
]
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +119
   System.Web.Mail.CdoSysHelper.Send(MailMessage message) +2684
   System.Web.Mail.SmtpMail.Send(MailMessage message) +131
   classes.Email.SendEmail(String strFrom, String strTo, String strSubject, String strBody) in \\Devserver\Inetpub\wwwroot\webprojects\classes\Email.vb:18
   EducationSurvey.SendSurvey.SendEmailToAttendees(DataTable dtQualifiedParticipants, String strSubject, String strBody) +151
   EducationSurvey.SendSurvey.Page_Load(Object sender, EventArgs e) +938
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

因为应用程序的几个部分以及可能我们内部网的其他旧部分正在调用这个类(类>电子邮件),我想修复它,或者弄清楚如何将类移动到生产服务器,此应用程序的发布位置。身份验证不能传递给类吗?

我希望有人能给我线索,或者告诉我要问什么!我无法确定...如果包含在页面代码隐藏中,以下是有效的功能:

    Function SendNow(ByVal strFrom As String, ByVal strTo As String, ByVal strSubject As String, ByVal strBody As String) As Object
        Dim msg As New MailMessage()
        Dim smtp As SmtpClient

        msg.From = New MailAddress(strFrom)
        msg.To.Add(strTo)
        msg.Subject = strSubject

        msg.Body = strBody

        smtp = New SmtpClient("echangeServerName")

        smtp.UseDefaultCredentials = True

        smtp.Send(msg)

        Return True

    End Function

但是,如果我将相同的代码放回类文件中,公共类电子邮件(位于项目解决方案之外)我会收到上面的传输错误。

【问题讨论】:

    标签: .net asp.net class smtp


    【解决方案1】:

    这可能与网络有关、DNS 问题或类似问题。

    在 www.systemwebmail.com (The transport failed to connect to the server) 上查找它提供了一些可能的想法。出于测试目的,我建议直接访问 IP 地址副 DNS 或 NETBIOS 名称。这可能会缩小问题范围并提供更多信息。

    跟踪还提到了 System.Web.Mail 命名空间的使用,但您的代码似乎正在使用 System.Net.Mail 命名空间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 1970-01-01
      • 2013-05-28
      • 2018-09-28
      • 2012-02-20
      • 2014-11-10
      相关资源
      最近更新 更多