questa è na parte di codice che uso attualmente, però è smtp, mi sembra di aver capito che devo usare imap. Ma imap non è un protocollo per la ricezione? non capisco sono un po confuso.
codice:
Public Function SendMail(ByVal dest As List(Of String), ByVal ob As String, ByVal mex As String, ByVal address As String, ByVal ricevuta As Boolean) As Boolean
Try
Dim x As New System.Net.Mail.SmtpClient()
Dim c As New System.Net.NetworkCredential(address, trovaPassword(address))
If address.Contains("@") = False Then
address = address & "@asolodolce.it"
End If
msg = New System.Net.Mail.MailMessage(address, dest(0), ob, mex)
If dest.Count > 1 Then
For Each d In dest
msg.CC.Add(d)
Next
End If
If allegato.Capacity <> 0 Then
For Each all In allegato
msg.Attachments.Add(New Net.Mail.Attachment(all))
Next
End If
x.UseDefaultCredentials = False
x.Credentials = c
x.Host = parametri(address, "smtp")
x.Port = parametri(address, "porta")
x.EnableSsl = parametri(address, "ssl")
msg.DeliveryNotificationOptions = Convert.ToDecimal(ricevuta)
x.Send(msg)
SendMail = True
Catch ex As Exception
SendMail = False
tsl1.Text = ex.Message
Try
If ex.InnerException.Message <> Nothing Then
tsl1.Text = tsl1.Text + ex.InnerException.Message
End If
Catch ex2 As Exception
End Try
End Try
End Function