班级位置导致的运输错误? (SMTP)

时间:2009-11-16 19:28:57

标签: .net asp.net class smtp

使用Integrated Auth + Impersonation的ASP.NET 2.0内部(Intranet)Web应用程序。在dev服务器(类所在的位置)上开发并发布到生产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

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

1 个答案:

答案 0 :(得分:0)

这可能与网络相关,DNS问题或类似问题。

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

跟踪还提到了System.Web.Mail命名空间的使用,但看起来您的代码使用的是System.Net.Mail命名空间。