Bonjour
Je développe en ce moment même une appli en interne pour la société pour laquelle je travaille et je rencontre un problème j'aimerai pouvoir envoyer une pièce jointe en mail en Vb tous fonctionne sauf la partie pour la pièce jointe.
Y'a-t-il une solution à mon problème ?
Code VB.NET : 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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 Imports System.Net.Mail Public Class Form5 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If tbdemandeur.Text = "" Or cbpriorite.Text = "" Or cbpanne.Text = "" Or tbdescription.Text = "" Or cbverif.Checked = False Then MsgBox("Vous devez remplire tous les champs") Exit Sub End If Dim Demandeur = tbdemandeur.Text Dim Priorite = cbpriorite.Text Dim Panne = cbpanne.Text Dim description = tbdescription.Text Dim parcourir = tbparcourir.Text Dim MyMailMessage As New MailMessage() Dim SMTPServer As New SmtpClient("smtp.gmail.com") MyMailMessage.From = New MailAddress("toto@gmail.com") MyMailMessage.To.Add("tot@gmail.com") MyMailMessage.Subject = ("Demande d'incident") MyMailMessage.Body = ("Demandeur : " & Demandeur & vbNewLine & "Priorite : " & Priorite & vbNewLine & "Panne : " & Panne & vbNewLine & "Description : " & description) SMTPServer.Port = ("587") 'Port SMTPServer.Credentials = New System.Net.NetworkCredential("toto@gmail.com", "toto") SMTPServer.EnableSsl = True SMTPServer.Send(MyMailMessage) 'Envoi If tbparcourir.Text <> "" Then Dim data = New Net.Mail.Attachment(tbparcourir.Text) MyMailMessage.Attachments.Add(data) End If Timer1.Start() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Button1.Enabled = False ProgressBar1.Increment(1) If ProgressBar1.Value = ProgressBar1.Maximum Then Timer1.Stop() MsgBox("votre demande a bien été prise en compte") ProgressBar1.Value = ProgressBar1.Minimum End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Form1.Show() Me.Hide() End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim dir As String = My.Computer.FileSystem.SpecialDirectories.Temp Dim filename As String = dir + "TeamViewerQS.exe" IO.File.WriteAllBytes(filename, My.Resources.TeamViewerQS) Process.Start(filename) End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Dim item As String = String.Empty item = OpenFileDialog1.FileName OpenFileDialog1.ShowDialog() tbparcourir.Text = item tbparcourir.Text = OpenFileDialog1.FileName End Sub Private Sub tbparcourir_TextChanged(sender As Object, e As EventArgs) Handles tbparcourir.TextChanged End Sub Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk End Sub End Class
Partager