u can use it
before using u can have valid gmail which use for NetworkCredentialcaditin
Public Sub SendMail(ByVal UserName As String, ByVal Pwd As String, ByVal From As String, ByVal To1 As String, ByVal Subject As String, ByVal Body As String)
Dim mailPath As New System.Net.NetworkCredential(UserName, Pwd)
Dim client As New SmtpClient("smtp.gmail.com", 587)
client.Credentials = mailPath
client.EnableSsl = True
Dim SendFrom As New MailAddress(From)
Dim SendTo As New MailAddress(To1)
Dim MyMessage = New System.Net.Mail.MailMessage(SendFrom, SendTo)
MyMessage.Subject = Subject
MyMessage.Body = Body
MyMessage.DeliveryNotificationOptions=DeliveryNotificationOptions.OnFailure
client.Send(MyMessage)
lblMsg.Text = "Your message has been sent successfully To:- " & "," & To1
End Sub
Protected Sub btnSendmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendMail.Click
Try
Dim Username As String = Session("EmailID")
Dim Pwd As String = Session("Password")
Dim From As String = Session("EmailID")
Dim To1 As String = Session("Email")
Dim Subject As String = txtSubject.Text
Dim Body As String = txtBody.Text
SendMail(Username, Pwd, From, To1, Subject, Body)
Catch ex As Exception
lblMsg.Text = "The message could not be sent" + ex.Message
End Try
End Sub