2011-07-13 65 views
0

我已經取得了一些進展,現在我得到這個錯誤爲什麼我在這段代碼中收到500錯誤

郵件無法發送到smtp服務器。傳輸錯誤代碼爲0x800ccc15

遠程服務器返回錯誤:(500)內部服務器錯誤。 描述:執行當前Web請求期間發生未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。

Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error. 

Source Error: 


Line 62:  Private Function HttpContent(ByVal url As String) As String 
Line 63:   Dim objRequest As Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url) 
Line 64:   Dim sr As New IO.StreamReader(objRequest.GetResponse().GetResponseStream()) 
Line 65:   Dim result As String = sr.ReadToEnd() 
Line 66:   sr.Close() 


Source File: C:\Inetpub\wwwroot\AB.com\wwwroot\bookingrequest\booking.aspx.vb Line: 64 

Stack Trace: 


[WebException: The remote server returned an error: (500) Internal Server Error.] 
    System.Net.HttpWebRequest.GetResponse() +5375997 
    _Default.HttpContent(String url) in C:\Inetpub\wwwroot\ABCdestionations.com\wwwroot\bookingrequest\booking.aspx.vb:64 
    _Default.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\ABCdestionations.com\wwwroot\bookingrequest\booking.aspx.vb:37 
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 

赫雷什,我認爲代碼的部分導致該錯誤

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 

     If Page.IsValid Then 
      SqlDataSource1.Insert() 
      Dim x As String 
      x = "http://www.cc.com/bookingrequest/confirm.aspx?date=" & HttpUtility.UrlEncode(now.Text) & "&tfname=" & HttpUtility.UrlEncode(lofname1.Text) & "&tlname=" & HttpUtility.UrlEncode(lolname1.Text) & "&comp=" & HttpUtility.UrlEncode(Request.QueryString("comp")) & "&land=" & HttpUtility.UrlEncode(land.Text) 
      Dim mail As New MailMessage() 
      mail.To = locemail.Text 
      mail.From = "[email protected]" 
      mail.Subject = "Booking Request for " + locfname.Text + " " + loclname.Text 
      Dim url As String 
      url = "http://www.cc.com/bookingrequest/email.aspx?date=" + now.Text + "&tfname=" + lofname1.Text + "&tlname=" + lolname1.Text + "&comp=" + Request.QueryString("comp") & "&land=" & HttpUtility.UrlEncode(land.Text) 
      mail.Body = HttpContent(url) + Environment.NewLine + "If You Can't See This E-mail, Please Click The Link. " + x 
      mail.BodyFormat = MailFormat.Html 
      mail.UrlContentBase = url 
      SmtpMail.SmtpServer = "mail.cc.com" 
      SmtpMail.Send(mail) 



      Dim mail1 As New MailMessage() 
      mail1.To = "[email protected]" 
      mail.Cc = "[email protected]" 
      mail1.From = "[email protected]" 
      mail1.Subject = "Booking Request for " + locfname.Text + " " + loclname.Text + " made by " & Request.QueryString("comp") 
      mail1.Body = HttpContent(url) + Environment.NewLine + "If You Can't See This E-mail, Please Click The Link. " + x 
      mail1.BodyFormat = MailFormat.Html 
      mail1.UrlContentBase = url 
      SmtpMail.SmtpServer = "mail.cc.com" 
      SmtpMail.Send(mail1) 

      Response.Redirect("http://www.cc.com/bookingrequest/confirm.aspx?date=" + now.Text + "&tfname=" + lofname1.Text + "&tlname=" + lolname1.Text + "&comp=" + Request.QueryString("comp") & "&land=" & HttpUtility.UrlEncode(land.Text)) 

     End If 

    End Sub 

    Private Function HttpContent(ByVal url As String) As String 
     Dim objRequest As Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url) 
     Dim sr As New IO.StreamReader(objRequest.GetResponse().GetResponseStream()) 
     Dim result As String = sr.ReadToEnd() 
     sr.Close() 
     Return result 
    End Function 

回答

0

由於遠程服務器不接受您的由於某種原因請求。我會嘗試在你的代碼生成的幾個url中手動打孔,看看他們是否給你提供任何想法。或者聯繫cc.com負責人,瞭解如何正確提交遠程請求。

通過猜測,鑑於它是.ASPX,它可能會期望您的Web客戶端處理會話cookie,並且可能在您沒有它們時崩潰。但從這裏可以肯定的是沒有多少可以確定的。

+0

奇怪的是它將信息寫入服務器,但它不發送電子郵件 –

相關問題