Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() SmtpServer.Credentials = New Net.NetworkCredential(TxtUserName.Text, TxtPassword.Text) SmtpServer.Port = 25 '25,26,578,468 etc... SmtpServer.Host = TxtServer.Text 'mail.gmail.com mail = New MailMessage() mail.From = New MailAddress(TxtUserName.Text) mail.To.Add(TxtSender.Text) mail.Subject = "Test Mail" mail.Body = "This is for testing SMTP mail from VB.NET" SmtpServer.Send(mail) MsgBox("mail send") Catch exc As Net.Mail.SmtpException MessageBox.Show(exc.Message.ToString, "Error?", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)