codice:
Imports System.IO
Imports System.Net.Mail
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Visible = False
Dim mail As New MailMessage()
Dim smtpServer As New SmtpClient()
smtpServer.Credentials = New Net.NetworkCredential("email", "pass")
smtpServer.Port = 587
smtpServer.Host = "smtp.xxxx.it"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("email")
mail.To.Add("email")
mail.Subject = "oggetto"
Dim msgatt As FileInfo = New FileInfo("C:\...\..")
If msgatt.Exists = True Then
Dim allegato As New Attachment("C:\...\..")
mail.Attachments.Add(allegato)
mail.Body = "il file è allegato!"
Else
mail.Body = "il file non esiste"
End If
smtpServer.Send(mail)
End Sub