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
| Shared Sub sendmail(ByVal strfrom As String, _
ByVal strTo As String, _
ByVal strsujet As String, _
ByVal strbody As String, _
ByVal strSMTP As String, _
ByVal iport As Integer, _
ByVal bssl As Boolean, _
ByVal strLogin As String, _
ByVal strpass As String)
Dim MyMailMessage As New MailMessage()
Try
MyMailMessage.From = New MailAddress(strfrom)
MyMailMessage.To.Add(strTo)
MyMailMessage.Subject = strsujet
MyMailMessage.Body = strbody
Dim SMTP As New SmtpClient(strSMTP)
SMTP.Port = iport
SMTP.EnableSsl = bssl
If strlogin <> "" Then SMTP.Credentials = New System.Net.NetworkCredential(strLogin, strPass)
'"From E-Mail Adress username and password"
SMTP.Send(MyMailMessage)
MsgBox("Message Envoyé!")
Catch ex As Exception
MsgBox("Message NON Envoyé!")
End Try
End Sub |
Partager