welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Thursday, January 20, 2011

Send email by using coding

hi folks...
This is a easy way to send a mail using vb coding...its very simple try this code & send you first email through

First you have to import the namespace for send the mail

 Dim log As String = " "
        Dim content As String = "This is my first mail using"
        Dim mail As MailMessage = New MailMessage()

        mail.To.Add("add sender email address")
        mail.From = New MailAddress(" your email address")
        mail.Subject = "Email using Gmail"

        mail.Body = content

        mail.IsBodyHtml = True
        Dim smtp As SmtpClient = New SmtpClient()
        smtp.Host = ""
        smtp.Credentials = New System.Net.NetworkCredential("your gmail username", " gmail password")
        smtp.EnableSsl = True
        Label1.Text = "your mail has sent"
        Catch ex As Exception
            Label1.Text = "The email cannot be sent" + ex.ToString()
        End Try


Post a Comment