1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage
smtpServer.Credentials = New Net.NetworkCredential(TextBox1.Text & ComboBox1.SelectedItem, TextBox2.Text)
smtpServer.Port = 587
smtpServer.Host = ComboBox2.SelectedItem
smtpServer.EnableSsl = True
mail.From = New MailAddress(TextBox1.Text & ComboBox1.SelectedItem)
If RadioButton1.Checked = True Then
mail.To.Add("33" & TextBox3.Text & "sms@gmailsms.com")
ElseIf RadioButton2.Checked = True Then
mail.To.Add(TextBox3.Text)
End If
mail.Subject = TextBox4.Text
mail.Body = TextBox5.Text()
smtpServer.Send(mail)
MsgBox("mail a etait envoyer", MsgBoxStyle.OkOnly, "ENVOYER")
Catch ex As Exception
MsgBox("Message n'a pas été envoyer" & Err.Description, MsgBoxStyle.OkOnly, "ERREUR")
End Try
End Sub |
Partager