Please help, it keeps on showing the exception msg "Failed" the message send never work
Imports System.Net.Mail
Imports System.Net.CredentialCache
Public Class Sendmail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
MsgBox("Please fill up all required fields")
Else
Dim Mail As New MailMessage
Mail = New MailMessage()
Mail.Subject = "EPOST OFFICE"
Mail.To.Add(TextBox2.Text)
Mail.From = New MailAddress(TextBox3.Text)
Mail.Body = TextBox1.Text
Dim Smtp As New SmtpClient
Smtp.Host = "Smtp.gmail.com"
Smtp.Port = 587
Smtp.EnableSsl = True
Smtp.Credentials = New System.Net.NetworkCredential(TextBox3.Text, TextBox4.Text)
Try
Smtp.Send(Mail)
MsgBox("Successfully")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Catch ex As Exception
MsgBox("failed")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Try
End If
End Sub