Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.  
  3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.         TextBox1.Text = My.Settings.username
  5.         TextBox2.Text = My.Settings.password
  6.  
  7.     End Sub
  8.  
  9.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  10.  
  11.         ProgressBar1.Value = 5
  12.         Dim message As System.Net.Mail.MailMessage
  13.         ProgressBar1.Value = 10
  14.         Dim smtp As New System.Net.Mail.SmtpClient(TextBox3.Text, 587)
  15.         ProgressBar1.Value = 24
  16.         message = New System.Net.Mail.MailMessage(TextBox1.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text)
  17.         ProgressBar1.Value = 43
  18.         smtp.EnableSsl = True
  19.         ProgressBar1.Value = 59
  20.         smtp.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
  21.         ProgressBar1.Value = 70
  22.         ProgressBar1.Value = 80
  23.         Try
  24.             smtp.Send(message)
  25.             ProgressBar1.Value = 100
  26.             MessageBox.Show("Message Sent Successfully", " Sent", MessageBoxButtons.OK, MessageBoxIcon.Information)
  27.             ProgressBar1.Value = 0
  28.         Catch exc As Net.Mail.SmtpException
  29.             MessageBox.Show("An Error Occured Please try again", " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  30.             MessageBox.Show("Try Entering your password again or maybe your not connected to the internet", " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  31.         End Try
  32.  
  33.         If CheckBox1.Checked = True Then
  34.             My.Settings.username = TextBox1.Text
  35.             My.Settings.Save()
  36.             My.Settings.Reload()
  37.         End If
  38.  
  39.         If CheckBox2.Checked = True Then
  40.             My.Settings.password = TextBox2.Text
  41.             My.Settings.Save()
  42.             My.Settings.Reload()
  43.         End If
  44.  
  45.     End Sub
  46.  
  47.     Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
  48.         My.Settings.password = ""
  49.         My.Settings.username = ""
  50.         My.Settings.Save()
  51.         My.Settings.Reload()
  52.         TextBox1.Text = ""
  53.         TextBox2.Text = ""
  54.  
  55.     End Sub
  56. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement