PROBLÈME:Code:
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 Imports System.Net.Mail Imports System.Net.Mail.SmtpClient Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim TheServer As String = "" Dim DE As String DE = TheServer If De.Contains("gmail") Then TheServer = "smtp.gmail.com" ElseIf De.Contains("hotmail") Then TheServer = "smtp.live.com" ElseIf De.Contains("yahoo") Then TheServer = "smtp.mail.yahoo.com" End If Dim Smtp As New SmtpClient(TheServer, 587) Dim EmailMessage As New MailMessage Try With EmailMessage .From = New MailAddress("fddsddf123@gmail.com") .To.Add("cvdss@yahoo.fr") .Subject = "test mail" .Body = "bonjour " End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try Try With Smtp .UseDefaultCredentials = False .DeliveryMethod = SmtpDeliveryMethod.Network .Timeout = 1 If TheServer = "smtp.mail.yahoo.com" Then .EnableSsl = False Else .EnableSsl = True End If .Credentials = New Net.NetworkCredential("fddsddf123@gmail.com", "mot de passe") .Send(EmailMessage) MsgBox("Message envoyé!", MsgBoxStyle.Information) End With Catch ex As Exception MsgBox("Echec d'envoi du message!", MsgBoxStyle.Critical) End Try End Sub End Class
le message "Echec d'envoi du message" s'affiche sans envoi de mail.
merci pour votre aide