Visual Studio 2005 を使用して簡単な連絡先フォームを設計しました。ページは正常に動作しますが、送信ボタンを押すと、次のようなエラーが表示されます。私のhotmailアカウントにVisual Studioを使用していますが、私のhotmailアカウントに電子メールを送信していません。エラーは次のとおりです。
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
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.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Source Error:
Line 24: Dim mailclient As SmtpClient = New SmtpClient
Line 25: mailclient.Host = mailServerName
Line 26: mailclient.Send(message)
Line 27: message.Dispose()
Line 28: End Sub
これは私のコントローラクラスです:
Imports System.Net.Mail
Partial Class ContactUs
Inherits System.Web.UI.Page
Protected Sub textComments_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Protected Sub textComments_TextChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtComments.TextChanged
End Sub
Protected Sub Send_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSend.Click
SendMail(txtEmail.Text, txtComments.Text)
End Sub
Private Sub SendMail(ByVal From As String, ByVal body As String)
Dim mailServerName As String = "mail.hotmail.com"
Dim message As MailMessage = New MailMessage(From, "Myaddress@hotmail.com", "Feedback", body)
Dim mailclient As SmtpClient = New SmtpClient
mailclient.Host = mailServerName
mailclient.Send(message)
message.Dispose()
End Sub
End Class
誰かが私の間違いを指摘できます。また、「Dim mailServerName As String = "mail.hotmail.com"」という行についても、ローカルメールサーバー名を取得する方法が正確にわからないため、「メール」と入力します。あなたの助けをいただければ幸いです。前もって感謝します