Visual Basic -smtpException未处理

时间:2015-10-02 10:56:00

标签: vb.net

一直试图通过visual basic发送电子邮件但遇到问题。每次我运行我或者得到错误“smtpException未处理”或“操作超时”任何帮助将不胜感激

Imports System.Web
Imports System.IO
Imports System.Net.Mail
Public Class Form1


Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click


    SmtpServer.Credentials = New Net.NetworkCredential("testemail1@gmail.com", "password")
    SmtpServer.Port = 465
    SmtpServer.Host = "smtp.gmail.com"
    SmtpServer.EnableSsl = True
    SmtpServer.EnableSsl = True
    mail.To.Add("testemail@hotmail.co.uk")
    mail.From = New MailAddress("testemail1@gmail.com")
    mail.Subject = "Match Reminder"
    mail.Body = "A reminder you have an upcoming match"
    SmtpServer.Send(mail)
End Sub

0 个答案:

没有答案