Advertisement
calfred2808

emailer

Jun 18th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.80 KB | None | 0 0
  1. Imports System.Net.Mail
  2.  
  3.  
  4. Public Class MainForm
  5.  
  6.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  7.         EmailNow()
  8.     End Sub
  9.  
  10.  
  11.     Public Sub EmailNow()
  12.  
  13.  
  14.         Dim SmtpServer As New SmtpClient()
  15.  
  16.         Dim mail As New MailMessage()
  17.  
  18.         SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "YOURPASSWORD")
  19.  
  20.         SmtpServer.Port = 587
  21.  
  22.         SmtpServer.Host = "smtp.gmail.com"
  23.  
  24.         mail = New MailMessage()
  25.  
  26.         mail.From = New MailAddress("[email protected]")
  27.  
  28.         mail.To.Add("[email protected]")
  29.  
  30.         mail.Subject = "Test Mail"
  31.  
  32.         mail.Body = "This is for testing SMTP mail from GMAIL"
  33.  
  34.         SmtpServer.Send(mail)
  35.  
  36.         MsgBox("mail send")
  37.  
  38.      
  39.     End Sub
  40.  
  41.  
  42. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement