2011-06-17 138 views
0
Imports System.Net.Mail 

Partial Class ContactUs 
    Inherits System.Web.UI.Page 
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click 
     Dim username = User.Identity.Name.ToString 
     Response.Redirect("~/ViewCart_aspx/ViewCart.aspx?userID=" & username) 
    End Sub 
    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate 
     If txtComments.Text.Length > 200 Then 
      args.IsValid = False 
     Else 
      args.IsValid = True 
     End If 
    End Sub 

    Protected Sub WizardStep3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles WizardStep3.Load 
     lblName.text = txtName.Text 
     lblEmail.Text = txtEmail.Text 
     lblComments.Text = txtComments.Text 
     lblRating.Text = txtRatings.Text 
    End Sub 
    Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick 
     SendMail(txtEmail.Text, txtComments.Text) 
     'MsgBox("Feedback Sent") 
     Response.Redirect("homepage_aspx/homepage.aspx") 

    End Sub 

    Private Sub SendMail(ByVal from As String, ByVal body As String) 

     Dim mMailSettings As System.Net.Configuration.MailSettingsSectionGroup 

     Dim mPort As Integer = mMailSettings.Smtp.Network.Port 
     Dim mHost As String = mMailSettings.Smtp.Network.Host 
     Dim mPassword As String = mMailSettings.Smtp.Network.Password 
     Dim mUsername As String = mMailSettings.Smtp.Network.UserName 
     'Dim mailServerName As String = "smtp.tricedeals.com" 
     'Dim message As MailMessage = New MailMessage(from, "[email protected]", "feedback", body) 
     'Dim mailClient As SmtpClient = New SmtpClient 

     'mailClient.Host = mailServerName 
     'mailClient.Send(message) 
     'message.Dispose() 
    End Sub 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
     Response.Cache.SetCacheability(HttpCacheability.NoCache) 
    End Sub 
End Class 

什麼是錯我的SMTP設置?我不能送emails.please幫助我。如何配置SMTP設置

+0

你觀察到了什麼行爲? – 2011-06-17 11:47:32

回答

2

由於發送命令已被註釋掉,您無法發送電子郵件。因爲你不會提供更多的細節或更好的解釋或異常消息,這是我可以承擔的唯一的事情。