tower7
asked on
ASP.net wizard Form using smtp
I wanted to create a feed back form using asp.net wizard function. I tried watching video and made the page but at the end when I tried to send the message I get an error.
The SMTP sever requires a secure connection or the client was not authenticated.
The server response was 5.7.0
I did expect this error becuase when you look at the code below, I did not find a place to put a password or a port number.
NEED HELP.
The SMTP sever requires a secure connection or the client was not authenticated.
The server response was 5.7.0
I did expect this error becuase when you look at the code below, I did not find a place to put a password or a port number.
NEED HELP.
Imports System.Net.Mail
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
If txtComments.Text.Length > 10 Then
args.IsValid = False
Else
args.IsValid = True
End If
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)
End Sub
Private Sub SendMail(ByVal from As String, ByVal body As String)
Dim mailServerName As String = "smtp.gmail.com"
Dim message As MailMessage = New MailMessage(from, "myemail@gmail.com", "feedback", body)
Dim mailClient As SmtpClient = New SmtpClient
mailClient.Host = mailServerName
mailClient.Send(message)
message.Dispose()
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.