Imports System.IO
Imports System.Net.Mail
Public Class Form1
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
End Sub
Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox4.PasswordChar = "*"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("กรุณาใส่ข้อมูลให้ครบ")
Else
Dim htmail As New MailMessage
With htmail
.From = New MailAddress("" + ListBox1.Text + "")
.To.Add("" + ListBox1.Text + "")
.Subject = ("" + TextBox2.Text + "")
.Body = ("To You : " & TextBox1.Text)
End With
Dim SMTPServer As New SmtpClient("" + ComboBox1.Text + "")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("" + TextBox3.Text + "", "" + TextBox4.Text + "")
SMTPServer.EnableSsl = True
SMTPServer.Send(htmail)
Try
MsgBox("ส่งสำเร็จ")
Catch ex As Exception
MsgBox("Failed Login")
End Try
End If
End Sub
Private Sub เพมรายชอผรบToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles เพมรายชอผรบToolStripMenuItem.Click
OpenFileDialog1.DefaultExt = "*.*"
OpenFileDialog1.AddExtension = True
OpenFileDialog1.Filter = "Text File|*.txt"
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
TextBox5.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox5.Text = "" Then
MsgBox("กรุณา Add File")
Else
Dim FileToLoad As String = "" + TextBox5.Text + ""
Dim fs As FileStream = New FileStream(FileToLoad, FileMode.Open)
Dim sr As StreamReader = New StreamReader(fs)
Do While Not sr.EndOfStream
ListBox1.Items.Add(sr.ReadLine)
Loop
sr.Close()
fs.Close()
TextBox5.Clear()
End If
End Sub
End Class