It is helpful for you-
Create a function:-
Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal subject As String, ByVal body As String)
' Instantiate a new instance of MailMessage
Dim mMailMessage As New MailMessage()
' Set the sender address of the mail message
mMailMessage.From = New MailAddress(from)
' Set the recepient address of the mail message
mMailMessage.To.Add(New MailAddress(recepient))
' Set the subject of the mail message
mMailMessage.Subject = subject
' Set the body of the mail message
mMailMessage.Body = body
' Set the format of the mail message body as HTML
mMailMessage.IsBodyHtml = True
' Set the priority of the mail message to normal
mMailMessage.Priority = MailPriority.Normal
' Instantiate a new instance of SmtpClient
Dim mSmtpClient As New SmtpClient()
' Send the mail message
mSmtpClient.Send(mMailMessage)
End Sub
Call That Function :-
Dim recep As String
Dim from as String
Dim body As String
Dim pass As String
Dim subject As String
from = dtResetPassword.Rows(0)("SenderName")
recep = dtResetPassword.Rows(0)("UserName")
pass = dtResetPassword.Rows(0)("Password")
body = "Your New Password Is" + " " + pass
subject = "Reset Password"
SendMailMessage(from, recep, subject, body)
ClientScript.RegisterStartupScript(Me.GetType(), Guid.NewGuid().ToString(), "alert('Your Mail Send Successfully');", True)
Pshrivastava
Gayathri, if this helps please login to Mark As Answer. | Alert Moderator