我想在我的VB.Net Windows應用程序(VS 2010)發送電子郵件,但我正在逐漸如何發送電子郵件在vb.net windows應用程序2010年,通過SMTP服務器使用Gmail憑證
SMTP找不到主機
我的代碼如下,
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "mypassword")
SmtpServer.Port = 25
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail = New MailMessage()
Dim addr() As String = TextBox1.Text.Split(",")
Try
mail.From = New MailAddress("[email protected]", "Developers", System.Text.Encoding.UTF8)
Dim i As Byte
For i = 0 To addr.Length - 1
mail.To.Add(addr(i))
Next
mail.Subject = TextBox3.Text
'mail.Body = TextBox4.Text
If ListBox1.Items.Count <> 0 Then
For i = 0 To ListBox1.Items.Count - 1
mail.Attachments.Add(New Attachment(ListBox1.Items.Item(i)))
Next
End If
SmtpServer.SendAsync(mail, mail.Subject)
優秀資源:http://www.systemnetmail.com/ – GJKH 2013-04-30 15:22:22