0

我必须从我的 VB 2012 应用程序发送一封电子邮件,并且我尝试了在网上找到的不同功能。我使用 System.Net.Mail 库 usign MailAddress、SmtpClient ecc。该应用程序没有给我任何例外,但没有发送电子邮件。与 VB 2010 应用程序相同的功能也可以在 2012 IDE 中完美运行。我不明白为什么=(看看我的功能

Private Sub InviaMailProva2(ByVal SmtpServer As String, ByVal usermail As String, ByVal sender As String, ByVal password As String, ByVal receiver As String, ByVal subject As String, ByVal body As String)
    Dim email As New MailMessage
    Dim smtp As New SmtpClient
    email.From = New MailAddress(usermail)
    email.Subject = subject
    email.To.Add(receiver)
    smtp.Port = 25     'i use an aruba email, it work with other application'
    smtp.Host = SmtpServer
    smtp.Credentials = New Net.NetworkCredential(user, password)
    smtp.Send(email)
End Sub
4

0 回答 0