Bonjour, je créé une application pour mes études et j'ai un petit problème concernant l'envoi d'un mail a partir d'un formulaire, voici mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Imports System.Net.Mail
Public Class Form1
    Dim MyMail As New MailMessage
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
    End Sub
 
    Private Sub Btnsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsubmit.Click
 
        Try
            Dim MySMTPClient As New SmtpClient("smtp.host.fr", 25)
            MyMail.From = New MailAddress("@.fr")
            MyMail.ReplyTo = New MailAddress(TxtMail.Text)
            MyMail.To.Add(New MailAddress("@.fr"))
            MyMail.Body = TxtLog.Text
            MyMail.Priority = MailPriority.High
            MyMail.Subject = Txtpass.Text
            For Each Lines As String In TxtLog.Lines
                MyMail.Attachments.Add(New Mail.Attachment(Lines))
            Next
            MySMTPClient.Send(MyMail)
            MsgBox("E-Mail bien envoyé !", MsgBoxStyle.Information, "Envoi de l'E-Mail")
            MyMail.To.Clear()
            MyMail.Attachments.Clear()
        Catch ex As Exception
            MsgBox("Impossible d'envoyer l'E-Mail.", MsgBoxStyle.Critical, "Envoi de l'E-Mail")
            MyMail.To.Clear()
            MyMail.Attachments.Clear()
 
        End Try
    End Sub
End Class
le mail est bien expedié en recupérant le mail de la TxtMail.text mais en revanche si je met quelques chose de le subject et body le mail n'est pas envoyé...Merci de votre aide