Envoyer un email avec vb.net
Bonsoir,
j'ai fait une application qui envoyer un email et voici la procedure que j'ecrit:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Public Sub SendMail(ByVal expediteur As String, ByVal destinataire As String, ByVal sujet As String, ByVal corps As String, ByVal serveur As String, ByVal port As String, _
ByVal username As String, ByVal password As String)
Dim from As New MailAddress(expediteur)
Dim [to] As New MailAddress(destinataire)
Dim message As New MailMessage(from, [to])
message.Subject = sujet
message.Body = corps
Dim smtp As New SmtpClient()
smtp.Host = serveur
' smtp.live.com pour hotmail; smtp.gmail.com pour gmail
smtp.Credentials = New NetworkCredential(username, password)
smtp.Port = Integer.Parse(port)
' 25 pour hotmail, 587 pour gmail
smtp.EnableSsl = True
smtp.DeliveryMethod = SmtpDeliveryMethod.Network
smtp.Send(message)
End Sub |
et voici le code d'appel a la procedure:
Code:
1 2 3 4
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendMail("XXXX@hotmail.fr", "XXXX@live.fr", "test", "test", "smtp.live.com", "25", "XXXX@hotmail.fr", "XXXX")
MsgBox("OK")
End Sub |
Mais il fait une erreur :
Citation:
Service non disponible, fermeture du canal de transmission. La réponse du serveur était : Cannot connect to SMTP server 65.55.162.200 (65.55.162.200:25), connect error 10060
Est que vous pouver m'aider?