Advertisement
Guest User

E-Mail/Brandonioproductions

a guest
Nov 26th, 2010
1,626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.07 KB | None | 0 0
  1. Imports System.Net.Mail
  2. Public Class Form1
  3.  
  4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  5.         Try
  6.             If TextBox1.Text = "" Then
  7.                 MsgBox("Error! No username")
  8.             Else
  9.                 If TextBox2.Text = "" Then
  10.                     MsgBox("Error! No Password")
  11.                 Else
  12.                     Dim message As New Net.Mail.MailMessage(TextBox1.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text)
  13.                     Dim smtp As New Net.Mail.SmtpClient("smtp.gmail.com", 465)
  14.                     Dim credentials As New Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
  15.                     smtp.EnableSsl = True
  16.                     smtp.Credentials = credentials
  17.                     smtp.Port = 465
  18.                     smtp.Host = "smtp.gmail.com"
  19.                     smtp.Send(message)
  20.                    MsgBox("Sent!")
  21.                 End If
  22.             End If
  23.         Catch ex As Exception
  24.             MsgBox(ex.Message)
  25.         End Try
  26.  
  27.     End Sub
  28. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement