Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'strings
Dim smtpserver As New SmtpClient
Dim mail As New MailMessage
Dim username As String
Dim password As String
'username/password
password = TextBox3.Text
username = TextBox2.Text
'@hotmail.com
If ComboBox1.Text = "@hotmail.com" Then
smtpserver.Credentials = New Net.NetworkCredential(username + ComboBox1.Text, password)
smtpserver.Host = "smtp.live.com"
smtpserver.Port = 25
smtpserver.EnableSsl = True
mail = New MailMessage
mail.From = New MailAddress(username + ComboBox1.Text)
End If
If ComboBox1.Text = "@live.com" Then
smtpserver.Credentials = New Net.NetworkCredential(username + ComboBox1.Text, password)
smtpserver.Host = "smtp.live.com"
smtpserver.Port = 25
smtpserver.EnableSsl = True
mail = New MailMessage
mail.From = New MailAddress(username + ComboBox1.Text)
End If
If ComboBox1.Text = "@Gmail.com" Then
smtpserver.Credentials = New Net.NetworkCredential(username + ComboBox1.Text, password)
smtpserver.Host = "smtp.Gmail.com"
smtpserver.Port = 587
smtpserver.EnableSsl = True
mail = New MailMessage
mail.From = New MailAddress(username + ComboBox1.Text)
End If
mail.To.Add(TextBox5.Text)
mail.Subject = TextBox4.Text
mail.Body = TextBox1.Text
smtpserver.Send(mail)
'Msgbox
MsgBox("Mail Sent")
end sub
end class