Imports System.Net.Mail
Public Class FrmEmail
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
Me.Refresh()
End Sub
Private Sub AttachFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AttachFileToolStripMenuItem.Click
FolderBrowserDialog1.ShowDialog()
End Sub
Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
Me.Close()
End Sub
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
Dim SmtpServer As New SmtpClient()
ProgressBar1.Value = 5
Dim Mail As New MailMessage()
ProgressBar1.Value = 10
SmtpServer.Credentials = New Net.NetworkCredential(userName:="TxtSendFrom.Text", password:="TxtPassword.Text")
TxtSendFrom.Text.EndsWith("@domain.com")
SmtpServer.Port = 25
SmtpServer.Host = "mail.domain.com"
SmtpServer.EnableSsl = False
Mail.To.Add(TxtSendTo.Text)
ProgressBar1.Value = 27
Mail.From = New MailAddress(TxtSendFrom.Text)
ProgressBar1.Value = 53
Mail.Subject = (TxtSubject.Text)
ProgressBar1.Value = 68
Mail.Body = (TxtBody.Text)
ProgressBar1.Value = 100
Try
SmtpServer.Send(Mail)
MsgBox("Your Email was sucessfully sent.", MsgBoxStyle.Information, "Technical Mailer")
ProgressBar1.Value = 0
Catch ex As Exception
MsgBox("An error has occured, Please verify your Email Address and / or Password!", MsgBoxStyle.Exclamation, "Technical Mailer")
ProgressBar1.Value = 0
End Try
End Sub
End Class
|