I am trying to use my gmail account for sendmail. I have a feedback.aspx page in VB.NET. The email sends to my gmail account fine. But it is not sending what I typed in the comment box and it keeps having the persons email address and keeps saying "no subject".
Now my question is how to I fix this code properly to send the comments?
Here's what I have with a few changes:
Now my question is how to I fix this code properly to send the comments?
Here's what I have with a few changes:
VB.NET:
Imports System.Net.Mail
Partial Class Feeback
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 SMTPServer As New SmtpClient("ASPMX.L.GOOGLE.COM")
Dim mailServerName As String = ("ASPMX.L.GOOGLE.COM")
Dim message As MailMessage = New MailMessage(from, "xxxxx@gmail.com")
Dim mailClient As SmtpClient = New SmtpClient
Dim MailMessage As New MailMessage()
SMTPServer.Port = 25
SMTPServer.Credentials = New System.Net.NetworkCredential("xxx@gmail.com", " xxxxxxxxxx")
SMTPServer.EnableSsl = True
MailMessage.To.Add("xxx@gmail.com")
MailMessage.Subject = "GMail Test"
MailMessage.Body = "This is the test text for Gmail email"
mailClient.Host = mailServerName
mailClient.Send(message)
message.Dispose()
End Sub
End Class
Last edited by a moderator: