Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

How to Send mail from visual basic 2010 professional

$
0
0

I want to send a mail using gmail id, my code is as here under, but its occurred error...please help me out of this issue.

Imports System.NetImports System.Net.Mail

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click    MsgBox("This will send a mail...")    Try        Dim smtpserver As New SmtpClient()        Dim mail As New MailMessage()        smtpserver.Credentials = New Net.NetworkCredential("myname@gmail.com", "password")        smtpserver.Port = 465        smtpserver.Host = "smtp.gmail.com"        mail = New MailMessage()        mail.From = New MailAddress("myname@gmail.com")        mail.To.Add("to mail id")        mail.Subject = "Test by bharat"        mail.Body = "hello ooooooooooooooooooooooo"        smtpserver.Send(mail)        MsgBox("Mail Sent")    Catch ex As Exception        MsgBox(ex.ToString)        Close()    End TryEnd Sub

End Class


Viewing all articles
Browse latest Browse all 29755

Trending Articles