Hi
I am new in vb.net. can any one give me code for sending the email in a butoon click.
Thanks
Mail sending in vb.net
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Gaurish Kumar108 reputationPosted Jan 31, 2010, 4:19 AM EST
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("[email protected]", "password")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("[email protected]")
mail.To.Add("TOADDRESS")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail from GMAIL"
SmtpServer.Send(mail)
MsgBox("mail send")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Paresh Sharma20 reputationPosted Jan 31, 2010, 4:25 AM EST
but i got the answer.
thanks once again.
Gaurish Kumar108 reputationPosted Jan 31, 2010, 4:29 AM EST
It's great that you have solved your problem by yourself.
Thanks