VB - Sending emails
In this tutorial you will learn how you can send emails using Visual Basic 2010.
Start by creating a new project, and call it Emailer or something like that.
Add some controls to your form to make it look like this:
2x Label
2x Textbox
1x Button
Double click your button to edit the codes behind your button.
First of all, we need to import a class..
Imports System.Net.Mail
Now, you need to add some codes to your button1_Click event:
TryDim SmtpServer As New SmtpClient()Dim mail As New MailMessage()SmtpServer.Credentials = New Net.NetworkCredential("username@gmail.com", "password") 'gmail email address and its passwordSmtpServer.Port = 587 'The portSmtpServer.Host = "smtp.gmail.com" 'Host is gmailmail = New MailMessage()mail.From = New MailAddress("username@gmail.com") 'Same email addres as used abovemail.To.Add("TOADDRESS") 'to e.g. blah@blah.commail.Subject = TextBox1.Text 'This is the subjectmail.Body = TextBox2.Text 'This is the messageSmtpServer.Send(mail)MsgBox("mail send")Catch ex As ExceptionMsgBox(ex.ToString)End Try
Remeber to change your credentials or otherwise this wont work.
I hope you found this tutorial useful.
You can download the source codes here:
Topic: VB - Sending emails
—————
—————
—————
—————
—————
—————
—————
—————
—————
—————