En ce moment :Genshin Impact, Valhalla, Breath of the wild, Animal Crossing, GTA 5, Red dead 2
PCPS5Xbox SeriesSwitch 2
Liste des sujets
[VB] Ajouter une piece jointe au mail
minerz
Niveau 10
05 juin 2012 à 18:38:34
Bonjour, je souhaiterais rajouter une pièce jointe à mon petit code pour envoyer un email avec gmail :
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim smtpServer As New SmtpClient() Dim mail As New MailMessage() smtpServer.Credentials = New Net.NetworkCredential("email", "mdp") smtpServer.Port = 587 smtpServer.Host = "smtp.gmail.com" smtpServer.EnableSsl = True mail = New MailMessage() mail.From = New MailAddress("Expéditeur") mail.To.Add("Destinataire") mail.Subject = "Sujet" mail.Body = "Message" smtpServer.Send(mail) End Sub End Class
Voilà, tout cela marche très bien mais je n'arrive pas à envoyer une pièce jointe ?
J'ai bien essayé mail.Attachments.add (C:\...) Mais il m'affiche une erreur "La propriété Attachments est Read Only"