1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Dim strAdresseMail As String = "*****@free.fr"
Dim mail As New MailMessage()
Try
'set the addresses
mail.From = New MailAddress(strAdresseMail)
mail.To.Add(strAdresseMail)
'set the content
mail.Subject = "Test envoi mail"
mail.Body = "Voir pièce jointe"
'add an attachment from the filesystem
mail.Attachments.Add(New Attachment(sDirectory & "\fichier.zip"))
'send the message
Dim smtp As New SmtpClient("smtp.free.fr")
smtp.Send(mail)
MessageBox.Show("Envoi terminé avec succès.", , MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Erreur lors de l'envoi." & vbCrLf & "Vérifiez votre serveur SMTP dans les préférences.", , MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
mail.Dispose()
mail = Nothing
End Try |
Partager