1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Imports System.Net.Mail
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim smtpServer As New SmtpClient()
ProgressBar1.Value = 10
Dim Mail As New MailMessage()
ProgressBar1.Value = 17
smtpServer.Credentials = New Net.NetworkCredential("username", "password")
ProgressBar1.Value = 23
'using gmail
smtpServer.Port = 587
ProgressBar1.Value = 28
smtpServer.Host = "smtp.gmail.com"
ProgressBar1.Value = 40
smtpServer.EnableSsl = True
Mail = New MailMessage()
Mail.From = New MailAddress("username@gmail.com")
Mail.To.Add("to@addrress.com")
Mail.Subject = ComboBox1.SelectedItem.ToString
Mail.Body = TextBox1.Text
smtpServer.Send(Mail)
MsgBox("Mail Envoyer")
End Sub
End Class |
Partager